Skip to content

Commit

Permalink
Check for *Error instead of ImportError in tests
Browse files Browse the repository at this point in the history
This tests originally checked for ImportError. Since Python 3.6
ModuleNotFoundError is raised in this context instead, the test didn't work
as it is text based (so exception inheritance does not save the day).

The test now simply checks for any *Error, which makes it less specific,
but still valuable.

Fixes pytest-dev#2132
  • Loading branch information
hroncok committed Dec 13, 2016
1 parent da40bcf commit ae7a32a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions testing/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,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*Error*",
"*Error: No module named *asdal*",
])

def test_doctest_unex_importerror_with_module(self, testdir):
Expand All @@ -227,7 +227,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*",
"*Error: No module named *asdals*",
"*Interrupted: 1 errors during collection*",
])

Expand Down

0 comments on commit ae7a32a

Please sign in to comment.