diff --git a/.travis.yml b/.travis.yml index c5a15140d6..f503eb5e17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,19 @@ matrix: - { python: "3.6", env: DJANGO=2.0 } - { python: "2.7", env: TOXENV=lint } - { python: "2.7", env: TOXENV=docs } - - python: "2.7" + + - python: "3.6" + env: TOXENV=dist + script: + - python setup.py bdist_wheel + - tox --installpkg ./dist/djangorestframework-*.whl + - tox # test sdist + + - python: "3.6" env: TOXENV=readme addons: apt_packages: pandoc + exclude: - { python: "2.7", env: DJANGO=master } - { python: "2.7", env: DJANGO=2.0 } diff --git a/runtests.py b/runtests.py index 5e8460c854..a8f818ad73 100755 --- a/runtests.py +++ b/runtests.py @@ -16,8 +16,6 @@ ISORT_ARGS = ['--recursive', '--check-only', '-o' 'uritemplate', '-p', 'tests', 'rest_framework', 'tests'] -sys.path.append(os.path.dirname(__file__)) - def exit_on_failure(ret, message=None): if ret: @@ -84,6 +82,20 @@ def is_class(string): run_flake8 = False run_isort = False + try: + # Remove the package root directory from `sys.path`, ensuring that rest_framework + # is imported from the installed site packages. Used for testing the distribution + sys.argv.remove('--no-pkgroot') + except ValueError: + pass + else: + sys.path.pop(0) + + # import rest_framework before pytest re-adds the package root directory. + import rest_framework + package_dir = os.path.join(os.getcwd(), 'rest_framework') + assert not rest_framework.__file__.startswith(package_dir) + if len(sys.argv) > 1: pytest_args = sys.argv[1:] first_arg = pytest_args[0] diff --git a/tox.ini b/tox.ini index e2d7aa4488..f04e6ba939 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envlist = {py27,py34,py35,py36}-django111, {py34,py35,py36}-django20, {py35,py36}-djangomaster, - lint,docs,readme, + dist,lint,docs,readme, [travis:env] DJANGO = @@ -18,6 +18,7 @@ DJANGO = [testenv] commands = ./runtests.py --fast {posargs} --coverage -rw +envdir = {toxworkdir}/venvs/{envname} setenv = PYTHONDONTWRITEBYTECODE=1 PYTHONWARNINGS=once @@ -29,6 +30,13 @@ deps = -rrequirements/requirements-testing.txt -rrequirements/requirements-optionals.txt +[testenv:dist] +commands = ./runtests.py --fast {posargs} --no-pkgroot -rw +deps = + django + -rrequirements/requirements-testing.txt + -rrequirements/requirements-optionals.txt + [testenv:lint] basepython = python2.7 commands = ./runtests.py --lintonly
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: