From bb90bf6de7c66897b14952b183f9975f07ec75d9 Mon Sep 17 00:00:00 2001 From: Matthew Iversen Date: Fri, 25 Apr 2014 12:08:17 +1000 Subject: [PATCH 1/3] remove tests subdir tox.ini, not needed --- tests/tox.ini | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 tests/tox.ini diff --git a/tests/tox.ini b/tests/tox.ini deleted file mode 100644 index da59e020d..000000000 --- a/tests/tox.ini +++ /dev/null @@ -1,12 +0,0 @@ -# Tox (http://codespeak.net/~hpk/tox/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - -[tox] -envlist = py25, py26, py27, py31, py32, pypy, jython -setupdir = .. - -[testenv] -commands = python setup.py test -changedir = .. From 869c468c71e3bca4c1d88d4871ce0bdb359a3ad1 Mon Sep 17 00:00:00 2001 From: Matthew Iversen Date: Mon, 28 Apr 2014 18:54:13 +1000 Subject: [PATCH 2/3] Change nose to pytest, clean up setup.py --- setup.py | 65 ++++++++++++++++++++++++++++++++++---------------------- tox.ini | 5 ++--- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/setup.py b/setup.py index ba330470b..89ca544cd 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,26 @@ try: from setuptools import setup + using_setuptools = True +except ImportError: + from distutils.core import setup + using_setuptools = False + +if using_setuptools: + from setuptools.command.test import test as TestCommand + + class PyTest(TestCommand): + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + + def run_tests(self): + # import here, because outside the eggs aren't loaded + import pytest + errno = pytest.main(self.test_args) + sys.exit(errno) + setup_params = { 'entry_points': { 'console_scripts': [ @@ -13,13 +33,13 @@ ], }, 'zip_safe': False, - 'test_suite': 'nose.collector', - 'tests_require': ['nose', 'Mock'], + 'tests_require': ['pytest', 'Mock'], + 'cmdclass': {'test': PyTest}, } -except ImportError: - from distutils.core import setup +else: if sys.platform == 'win32': - print('Note: without Setuptools installed you will have to use "python -m virtualenv ENV"') + print('Note: without Setuptools installed you will' + 'have to use "python -m virtualenv ENV"') setup_params = {} else: script = 'scripts/virtualenv' @@ -27,22 +47,26 @@ shutil.copy(script, script_ver) setup_params = {'scripts': [script, script_ver]} + here = os.path.dirname(os.path.abspath(__file__)) -## Get long_description from index.txt: -f = open(os.path.join(here, 'docs', 'index.rst')) -long_description = f.read().strip() -long_description = long_description.split('split here', 1)[0] -f.close() -f = open(os.path.join(here, 'docs', 'news.rst')) -long_description += "\n\n" + f.read() -f.close() + +def read_file(*paths): + file_path = os.path.join(*([here] + list(paths))) + f = open(file_path) + contents = f.read().strip() + f.close() + + return contents + +index = read_file('docs', 'index.rst') +news = read_file('docs', 'news.rst') + +long_description = index.split('split here', 1)[0] + '\n\n' + news def get_version(): - f = open(os.path.join(here, 'virtualenv.py')) - version_file = f.read() - f.close() + version_file = read_file('virtualenv.py') version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: @@ -50,15 +74,6 @@ def get_version(): raise RuntimeError("Unable to find version string.") -# Hack to prevent stupid TypeError: 'NoneType' object is not callable error on -# exit of python setup.py test # in multiprocessing/util.py _exit_function when -# running python setup.py test (see -# http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html) -try: - import multiprocessing -except ImportError: - pass - setup( name='virtualenv', version=get_version(), diff --git a/tox.ini b/tox.ini index d9791c2f1..746349ccd 100644 --- a/tox.ini +++ b/tox.ini @@ -4,8 +4,7 @@ envlist = [testenv] deps = - nose + pytest mock commands = - nosetests -v tests - python virtualenv.py {envtmpdir}/test-venv-01 + py.test [] From 17ef0955a214fe8875643f990ed1e4a5df0f6c43 Mon Sep 17 00:00:00 2001 From: Matthew Iversen Date: Tue, 29 Apr 2014 19:46:16 +1000 Subject: [PATCH 3/3] Add sphinx docs testing --- docs/index.rst | 1 + tox.ini | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 1e386c3d4..ae95716c0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,3 +17,4 @@ Dev IRC: #pypa-dev :maxdepth: 2 virtualenv + news diff --git a/tox.ini b/tox.ini index 746349ccd..f9381fef5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py26,py27,py32,py33,pypy + docs,py26,py27,py32,py33,pypy [testenv] deps = @@ -8,3 +8,9 @@ deps = mock commands = py.test [] + +[testenv:docs] +deps = sphinx +basepython = python2.7 +commands = + sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html