Merge pull request #6005 from blueyed/harden-trial

tests: harden/fix test_trial_error
This commit is contained in:
Daniel Hahler 2019-10-20 17:35:15 +02:00 committed by GitHub
commit fbb7f663be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 7 deletions

View File

@ -233,7 +233,7 @@ def test_unittest_skip_issue148(testdir):
def test_method_and_teardown_failing_reporting(testdir): def test_method_and_teardown_failing_reporting(testdir):
testdir.makepyfile( testdir.makepyfile(
""" """
import unittest, pytest import unittest
class TC(unittest.TestCase): class TC(unittest.TestCase):
def tearDown(self): def tearDown(self):
assert 0, "down1" assert 0, "down1"
@ -530,19 +530,31 @@ class TestTrialUnittest:
# will crash both at test time and at teardown # will crash both at test time and at teardown
""" """
) )
result = testdir.runpytest() # Ignore DeprecationWarning (for `cmp`) from attrs through twisted,
# for stable test results.
result = testdir.runpytest(
"-vv", "-oconsole_output_style=classic", "-W", "ignore::DeprecationWarning"
)
result.stdout.fnmatch_lines( result.stdout.fnmatch_lines(
[ [
"test_trial_error.py::TC::test_four FAILED",
"test_trial_error.py::TC::test_four ERROR",
"test_trial_error.py::TC::test_one FAILED",
"test_trial_error.py::TC::test_three FAILED",
"test_trial_error.py::TC::test_two FAILED",
"*ERRORS*", "*ERRORS*",
"*_ ERROR at teardown of TC.test_four _*",
"*DelayedCalls*", "*DelayedCalls*",
"*test_four*", "*= FAILURES =*",
"*_ TC.test_four _*",
"*NameError*crash*", "*NameError*crash*",
"*test_one*", "*_ TC.test_one _*",
"*NameError*crash*", "*NameError*crash*",
"*test_three*", "*_ TC.test_three _*",
"*DelayedCalls*", "*DelayedCalls*",
"*test_two*", "*_ TC.test_two _*",
"*crash*", "*NameError*crash*",
"*= 4 failed, 1 error in *",
] ]
) )