add setuputil based test running and makefile support
Signed-off-by: Harsha Narayana <harsha2k4@gmail.com>
This commit is contained in:
parent
87ab0b386d
commit
4880761fe0
23
MANIFEST.in
23
MANIFEST.in
|
@ -1,27 +1,14 @@
|
||||||
# Non Code related contents
|
# Non Code related contents
|
||||||
include LICENSE *.rst *.md *.yml *.toml Makefile *.cfg
|
include LICENSE
|
||||||
graft .github
|
include README.rst
|
||||||
|
|
||||||
# Release
|
# Setup
|
||||||
include release.py
|
|
||||||
include setup.py
|
include setup.py
|
||||||
|
include Makefile
|
||||||
# Requirements
|
|
||||||
include *.txt
|
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
include tox.ini .coveragerc
|
include .coveragerc
|
||||||
graft tests
|
graft tests
|
||||||
|
|
||||||
# Examples
|
|
||||||
graft examples
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
graft docs
|
|
||||||
prune docs/_build
|
|
||||||
|
|
||||||
# Docker setup
|
|
||||||
graft docker
|
|
||||||
|
|
||||||
global-exclude __pycache__
|
global-exclude __pycache__
|
||||||
global-exclude *.py[co]
|
global-exclude *.py[co]
|
34
Makefile
34
Makefile
|
@ -1,4 +1,34 @@
|
||||||
test:
|
.PHONY: help test test-coverage install docker-test
|
||||||
find . -name "*.pyc" -delete
|
|
||||||
|
.DEFAULT: help
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Please use \`make <target>' where <target> is one of"
|
||||||
|
@echo "test"
|
||||||
|
@echo " Run Sanic Unit Tests"
|
||||||
|
@echo "test-coverage"
|
||||||
|
@echo " Run Sanic Unit Tests with Coverage"
|
||||||
|
@echo "install"
|
||||||
|
@echo " Install Sanic"
|
||||||
|
@echo "docker-test"
|
||||||
|
@echo " Run Sanic Unit Tests using Docker"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
clean:
|
||||||
|
find . ! -path "./.eggs/*" -name "*.pyc" -exec rm {} \;
|
||||||
|
find . ! -path "./.eggs/*" -name "*.pyo" -exec rm {} \;
|
||||||
|
rm -rf build/* > /dev/null 2>&1
|
||||||
|
rm -rf dist/* > /dev/null 2>&1
|
||||||
|
|
||||||
|
test: clean
|
||||||
|
python setup.py test
|
||||||
|
|
||||||
|
test-coverage: clean
|
||||||
|
python setup.py test --pytest-args="--cov sanic --cov-report term --cov-append "
|
||||||
|
|
||||||
|
install:
|
||||||
|
python setup.py install
|
||||||
|
|
||||||
|
docker-test: clean
|
||||||
docker build -t sanic/test-image -f docker/Dockerfile .
|
docker build -t sanic/test-image -f docker/Dockerfile .
|
||||||
docker run -t sanic/test-image tox
|
docker run -t sanic/test-image tox
|
||||||
|
|
37
setup.py
37
setup.py
|
@ -4,10 +4,25 @@ Sanic
|
||||||
import codecs
|
import codecs
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from distutils.errors import DistutilsPlatformError
|
import sys
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
from setuptools.command.test import test as TestCommand
|
||||||
|
|
||||||
|
|
||||||
|
class PyTest(TestCommand):
|
||||||
|
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
TestCommand.initialize_options(self)
|
||||||
|
self.pytest_args = ''
|
||||||
|
|
||||||
|
def run_tests(self):
|
||||||
|
import shlex
|
||||||
|
import pytest
|
||||||
|
errno = pytest.main(shlex.split(self.pytest_args))
|
||||||
|
sys.exit(errno)
|
||||||
|
|
||||||
|
|
||||||
def open_local(paths, mode='r', encoding='utf8'):
|
def open_local(paths, mode='r', encoding='utf8'):
|
||||||
|
@ -26,7 +41,6 @@ with open_local(['sanic', '__init__.py'], encoding='latin1') as fp:
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise RuntimeError('Unable to determine version.')
|
raise RuntimeError('Unable to determine version.')
|
||||||
|
|
||||||
|
|
||||||
with open_local(['README.rst']) as rm:
|
with open_local(['README.rst']) as rm:
|
||||||
long_description = rm.read()
|
long_description = rm.read()
|
||||||
|
|
||||||
|
@ -64,14 +78,33 @@ requirements = [
|
||||||
'websockets>=6.0,<7.0',
|
'websockets>=6.0,<7.0',
|
||||||
'multidict>=4.0,<5.0',
|
'multidict>=4.0,<5.0',
|
||||||
]
|
]
|
||||||
|
tests_require = [
|
||||||
|
'pytest==3.3.2',
|
||||||
|
'multidict>=4.0,<5.0',
|
||||||
|
'gunicorn',
|
||||||
|
'pytest-cov',
|
||||||
|
'aiohttp>=2.3.0,<=3.2.1',
|
||||||
|
'beautifulsoup4',
|
||||||
|
uvloop,
|
||||||
|
ujson,
|
||||||
|
'pytest-sanic',
|
||||||
|
'pytest-sugar'
|
||||||
|
]
|
||||||
|
|
||||||
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
|
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
|
||||||
print("Installing without uJSON")
|
print("Installing without uJSON")
|
||||||
requirements.remove(ujson)
|
requirements.remove(ujson)
|
||||||
|
tests_require.remove(ujson)
|
||||||
|
|
||||||
# 'nt' means windows OS
|
# 'nt' means windows OS
|
||||||
if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")):
|
if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")):
|
||||||
print("Installing without uvLoop")
|
print("Installing without uvLoop")
|
||||||
requirements.remove(uvloop)
|
requirements.remove(uvloop)
|
||||||
|
tests_require.remove(uvloop)
|
||||||
|
|
||||||
setup_kwargs['install_requires'] = requirements
|
setup_kwargs['install_requires'] = requirements
|
||||||
|
setup_kwargs['tests_require'] = tests_require
|
||||||
|
setup_kwargs['cmdclass'] = {
|
||||||
|
'test': PyTest
|
||||||
|
}
|
||||||
setup(**setup_kwargs)
|
setup(**setup_kwargs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user