diff --git a/.travis.yml b/.travis.yml index bbc03d856ce..c4699ec4bc5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,9 @@ matrix: allow_failures: # py35-trial failing on Linux: #1989 - env: TESTENV=py35-trial + include: + - env: TESTENV=py36 + python: '3.6-dev' script: tox --recreate -e $TESTENV diff --git a/_pytest/compat.py b/_pytest/compat.py index 51fc3bc5c1b..8f4d0a8e6a9 100644 --- a/_pytest/compat.py +++ b/_pytest/compat.py @@ -26,6 +26,9 @@ NoneType = type(None) NOTSET = object() +PY36 = sys.version_info[:2] >= (3, 6) +MODULE_NOT_FOUND_ERROR = 'ModuleNotFoundError' if PY36 else 'ImportError' + if hasattr(inspect, 'signature'): def _format_args(func): return str(inspect.signature(func)) diff --git a/testing/test_doctest.py b/testing/test_doctest.py index 4ea2cc58eb6..faf75ef3396 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -1,9 +1,11 @@ # encoding: utf-8 import sys import _pytest._code +from _pytest.compat import MODULE_NOT_FOUND_ERROR from _pytest.doctest import DoctestItem, DoctestModule, DoctestTextfile import pytest + class TestDoctests: def test_collect_testtextfile(self, testdir): @@ -211,8 +213,8 @@ def test_doctest_unex_importerror_only_txt(self, testdir): # doctest is never executed because of error during hello.py collection result.stdout.fnmatch_lines([ "*>>> import asdals*", - "*UNEXPECTED*ImportError*", - "ImportError: No module named *asdal*", + "*UNEXPECTED*{e}*".format(e=MODULE_NOT_FOUND_ERROR), + "{e}: No module named *asdal*".format(e=MODULE_NOT_FOUND_ERROR), ]) def test_doctest_unex_importerror_with_module(self, testdir): @@ -227,7 +229,7 @@ def test_doctest_unex_importerror_with_module(self, testdir): # doctest is never executed because of error during hello.py collection result.stdout.fnmatch_lines([ "*ERROR collecting hello.py*", - "*ImportError: No module named *asdals*", + "*{e}: No module named *asdals*".format(e=MODULE_NOT_FOUND_ERROR), "*Interrupted: 1 errors during collection*", ]) diff --git a/tox.ini b/tox.ini index f3494e8be72..a5dec3fdc5a 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ envlist= py33 py34 py35 + py36 pypy {py27,py35}-{pexpect,xdist,trial} py27-nobyte