MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_trial_error

Method test_trial_error

testing/test_unittest.py:535–597  ·  view source on GitHub ↗
(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

533 assert result.ret == 1
534
535 def test_trial_error(self, pytester: Pytester) -> None:
536 pytester.makepyfile(
537 """
538 from twisted.trial.unittest import TestCase
539 from twisted.internet.defer import Deferred
540 from twisted.internet import reactor
541
542 class TC(TestCase):
543 def test_one(self):
544 crash
545
546 def test_two(self):
547 def f(_):
548 crash
549
550 d = Deferred()
551 d.addCallback(f)
552 reactor.callLater(0.3, d.callback, None)
553 return d
554
555 def test_three(self):
556 def f():
557 pass # will never get called
558 reactor.callLater(0.3, f)
559 # will crash at teardown
560
561 def test_four(self):
562 def f(_):
563 reactor.callLater(0.3, f)
564 crash
565
566 d = Deferred()
567 d.addCallback(f)
568 reactor.callLater(0.3, d.callback, None)
569 return d
570 # will crash both at test time and at teardown
571 """
572 )
573 result = pytester.runpytest(
574 "-vv", "-oconsole_output_style=classic", "-W", "ignore::DeprecationWarning"
575 )
576 result.stdout.fnmatch_lines(
577 [
578 "test_trial_error.py::TC::test_four FAILED",
579 "test_trial_error.py::TC::test_four ERROR",
580 "test_trial_error.py::TC::test_one FAILED",
581 "test_trial_error.py::TC::test_three FAILED",
582 "test_trial_error.py::TC::test_two FAILED",
583 "*ERRORS*",
584 "*_ ERROR at teardown of TC.test_four _*",
585 "*DelayedCalls*",
586 "*= FAILURES =*",
587 "*_ TC.test_four _*",
588 "*NameError*crash*",
589 "*_ TC.test_one _*",
590 "*NameError*crash*",
591 "*_ TC.test_three _*",
592 "*DelayedCalls*",

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected