Skip to content

Commit

Permalink
Merge pull request #49 from zopefoundation/py36
Browse files Browse the repository at this point in the history
Support Python 3.6
  • Loading branch information
mgedmin committed Dec 28, 2016
2 parents 64f1e20 + e04cb43 commit 18bf67e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -5,6 +5,7 @@ python:
- 3.3
- 3.4
- 3.5
- 3.6
- pypy
- pypy3.3-5.2-alpha1
matrix:
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,9 @@ zope.testrunner Changelog
``zope.testrunner[subunit]`` to their ``install_requires`` or else
depend directly on ``python-subunit``.

- Support Python 3.6.


4.5.1 (2016-06-20)
==================

Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -154,6 +154,7 @@ def run_tests(self):
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
15 changes: 5 additions & 10 deletions src/zope/testrunner/runner.py
Expand Up @@ -55,14 +55,8 @@
# Python 3
import queue as Queue # Python 3

try:
from unittest import _UnexpectedSuccess # Python 3.1
except ImportError:
try:
from unittest.case import _UnexpectedSuccess # Python 2.7 and 3.2
except ImportError:
class _UnexpectedSuccess(Exception):
pass
class UnexpectedSuccess(Exception):
pass


PYREFCOUNT_PATTERN = re.compile('\[[0-9]+ refs\]')
Expand Down Expand Up @@ -825,8 +819,9 @@ def addExpectedFailure(self, test, exc_info):
unittest.TestResult.addExpectedFailure(self, test, exc_info)

def addUnexpectedSuccess(self, test):
self.options.output.test_error(test, time.time() - self._start_time,
(_UnexpectedSuccess, None, None))
self.options.output.test_error(
test, time.time() - self._start_time,
(UnexpectedSuccess, UnexpectedSuccess(), None))

unittest.TestResult.addUnexpectedSuccess(self, test)

Expand Down
39 changes: 23 additions & 16 deletions src/zope/testrunner/tests/test_doctest.py
Expand Up @@ -95,6 +95,9 @@
(re.compile(r'builtins\.(SyntaxError|TypeError)'),
r'exceptions.\1'),

# Python 3.6 introduces ImportError subclasses
(re.compile(r'ModuleNotFoundError:'), 'ImportError:'),

# Python 3.3 has better exception messages
(re.compile("ImportError: No module named '(?:[^']*[.])?([^'.]*)'"),
r'ImportError: No module named \1'),
Expand Down Expand Up @@ -160,6 +163,9 @@
(re.compile(r'builtins\.(SyntaxError|TypeError)'),
r'exceptions.\1'),

# Python 3.6 introduces ImportError subclasses
(re.compile(r'ModuleNotFoundError:'), 'ImportError:'),

# Python 3.3 has better exception messages
(re.compile("ImportError: No module named '(?:[^']*[.])?([^'.]*)'"),
r'ImportError: No module named \1'),
Expand Down Expand Up @@ -194,6 +200,9 @@ def tearDown(test):


def test_suite():
optionflags = (doctest.ELLIPSIS |
doctest.NORMALIZE_WHITESPACE |
doctest.REPORT_NDIFF)
suites = [
doctest.DocFileSuite(
'testrunner-arguments.txt',
Expand Down Expand Up @@ -225,11 +234,11 @@ def test_suite():
'testrunner-eggsupport.txt',
'testrunner-stops-when-stop-on-error.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker),
doctest.DocTestSuite('zope.testrunner'),
doctest.DocTestSuite('zope.testrunner.coverage',
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE),
optionflags=optionflags),
doctest.DocTestSuite('zope.testrunner.options'),
doctest.DocTestSuite('zope.testrunner.find'),
]
Expand All @@ -240,7 +249,7 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-gc.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker))

# PyPy does not support sourceless imports, apparently (tried version 1.9)
Expand All @@ -249,15 +258,15 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-wo-source.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker))

if sys.platform == 'win32':
suites.append(
doctest.DocFileSuite(
'testrunner-coverage-win32.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker))

# Python <= 2.4.1 had a bug that prevented hotshot from running in
Expand All @@ -274,7 +283,7 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-profiling.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker = renormalizing.RENormalizing([
(re.compile(r'tests_profile[.]\S*[.]prof'),
'tests_profile.*.prof'),
Expand All @@ -291,7 +300,7 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-profiling-cprofiler.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker = renormalizing.RENormalizing([
(re.compile(r'tests_profile[.]\S*[.]prof'),
'tests_profile.*.prof'),
Expand All @@ -303,7 +312,7 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-report-skipped.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker)
)

Expand All @@ -312,7 +321,7 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-leaks.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker = renormalizing.RENormalizing([
(re.compile(r'(\d+ minutes )?\d+[.]\d\d\d seconds'), 'N.NNN seconds'),
(re.compile(r'sys refcount=\d+ +change=\d+'),
Expand All @@ -332,7 +341,7 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-leaks-err.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker,
)
)
Expand All @@ -344,31 +353,29 @@ def test_suite():
doctest.DocFileSuite(
'testrunner-subunit-err.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker))
else:
suites.append(
doctest.DocFileSuite(
'testrunner-subunit.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
doctest.REPORT_NDIFF,
optionflags=optionflags,
checker=checker))
if hasattr(sys, 'gettotalrefcount'):
suites.append(
doctest.DocFileSuite(
'testrunner-subunit-leaks.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker))

if sys.version_info[:3] >= (2,7,0):
# Python 2.7 adds support for unittest.expectedFailure
suites.append(doctest.DocFileSuite(
'testrunner-unexpected-success.txt',
setUp=setUp, tearDown=tearDown,
optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
optionflags=optionflags,
checker=checker))

return unittest.TestSuite(suites)
Expand Up @@ -37,7 +37,7 @@ affecting the Python path:
<BLANKLINE>
Error in test test_ef (sampletestsf.TestUnexpectedSuccess)
Traceback (most recent call last):
..._UnexpectedSuccess
...UnexpectedSuccess
<BLANKLINE>
Ran 1 tests with 1 failures, 0 errors and 0 skipped in N.NNN seconds.
Tearing down left over layers:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,6 +1,6 @@
[tox]
envlist =
py27,pypy,py33,py34,py35,pypy3,py27-subunit,pypy-subunit
py27,pypy,py33,py34,py35,py36,pypy3,py27-subunit,pypy-subunit

[testenv]
deps =
Expand Down

0 comments on commit 18bf67e

Please sign in to comment.