Skip to content

Commit

Permalink
Drop support for 'setup.py test'. Fixes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Oct 4, 2018
1 parent 4dbbb59 commit 9dd9f3e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
- pip install -U coverage coveralls
- pip install -U -e .[test]
script:
- coverage run setup.py -q test -q
- coverage run -m zope.testrunner --test-path=.
notifications:
email: false
after_success:
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Change History for ZConfig
3.3.0 (unreleased)
------------------

- Drop support for 'python setup.py test'. See `issue 38
<https://github.com/zopefoundation/ZConfig/issues/38>`_.

- Add support for ``example`` in ``section`` and ``multisection``, and
include those examples in generated documentation. See
https://github.com/zopefoundation/ZConfig/pull/5.
Expand Down
19 changes: 14 additions & 5 deletions ZConfig/tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
options = doctest.REPORT_NDIFF | doctest.ELLIPSIS

old = {}

def setUp(test):
logger = logging.getLogger()
old['level'] = logger.level
Expand All @@ -34,6 +35,15 @@ def tearDown(test):
logger.level = old['level']
logger.handlers = old['handlers']

def findRoot():
here = os.path.dirname(os.path.abspath(__file__))
while not os.path.exists(os.path.join(here, 'setup.py')):
prev, here = here, os.path.dirname(here)
if here == prev:
# Let's avoid infinite loops at root
raise AssertionError('could not find my setup.py')
return here

def docSetUp(test):
# Python 2 makes __path__ and __file__ relative in some
# cases (such as when we're executing with the 'ZConfig'
Expand All @@ -45,9 +55,7 @@ def docSetUp(test):

old['pwd'] = os.getcwd()
doc_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'..',
'..',
findRoot(),
'doc')
os.chdir(doc_path)
setUp(test)
Expand All @@ -58,17 +66,18 @@ def docTearDown(test):
old.clear()

def test_suite():
root = findRoot()
plugins = manuel.doctest.Manuel(optionflags=options)
plugins += manuel.capture.Manuel()
return unittest.TestSuite([
manuel.testing.TestSuite(
plugins,
'../../README.rst',
os.path.join(root, 'README.rst'),
setUp=setUp, tearDown=tearDown,
),
manuel.testing.TestSuite(
plugins,
'../../doc/using-logging.rst',
os.path.join(root, 'doc', 'using-logging.rst'),
globs={'resetLoggers': lambda: tearDown(None)},
setUp=docSetUp, tearDown=docTearDown,
),
Expand Down
16 changes: 0 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@
with open("CHANGES.rst") as f:
CHANGES = f.read()

def alltests():
import os
import sys
import unittest
# use the zope.testrunner machinery to find all the
# test suites we've put under ourselves
import zope.testrunner.find
import zope.testrunner.options
here = os.path.abspath(os.path.dirname(sys.argv[0]))
args = sys.argv[:]
defaults = ["--test-path", here]
options = zope.testrunner.options.get_options(args, defaults)
suites = list(zope.testrunner.find.find_suites(options))
return unittest.TestSuite(suites)

tests_require = [
'docutils',
Expand Down Expand Up @@ -80,8 +66,6 @@ def alltests():
'Operating System :: OS Independent',
'Topic :: Software Development',
],
# Support for 'setup.py test' when setuptools is available:
test_suite='__main__.alltests',
tests_require=tests_require,
extras_require={
'test': tests_require,
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ envlist = py27,py34,py35,py36,pypy

[testenv]
commands =
python setup.py -q test -q
# without explicit deps, setup.py test will download a bunch of eggs into $PWD
zope-testrunner --test-path=.
deps =
.[test]

[testenv:coverage]
basepython =
python2.7
commands =
coverage run setup.py -q test -q
coverage run -m zope.testrunner --test-path=.
coverage report -m --fail-under=99
deps =
coverage
Expand Down

0 comments on commit 9dd9f3e

Please sign in to comment.