A test for trial
This commit is contained in:
parent
9be1cd8007
commit
233baecd2d
|
@ -1,6 +1,6 @@
|
||||||
""" discovery and running of std-library "unittest" style tests. """
|
""" discovery and running of std-library "unittest" style tests. """
|
||||||
import pytest, py
|
import pytest, py
|
||||||
import sys
|
import sys, pdb
|
||||||
|
|
||||||
def pytest_pycollect_makeitem(collector, name, obj):
|
def pytest_pycollect_makeitem(collector, name, obj):
|
||||||
unittest = sys.modules.get('unittest')
|
unittest = sys.modules.get('unittest')
|
||||||
|
@ -96,7 +96,9 @@ def pytest_runtest_protocol(item, __multicall__):
|
||||||
if exc_value is None:
|
if exc_value is None:
|
||||||
self._rawexcinfo = sys.exc_info()
|
self._rawexcinfo = sys.exc_info()
|
||||||
else:
|
else:
|
||||||
self._rawexcinfo = (exc_value, exc_type, exc_tb)
|
if exc_type is None:
|
||||||
|
exc_type = type(exc_value)
|
||||||
|
self._rawexcinfo = (exc_type, exc_value, exc_tb)
|
||||||
Failure__init__(self, exc_value, exc_type, exc_tb)
|
Failure__init__(self, exc_value, exc_type, exc_tb)
|
||||||
ut.Failure.__init__ = excstore
|
ut.Failure.__init__ = excstore
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -225,6 +225,38 @@ class TestTrialUnittest:
|
||||||
"*3 skipped*2 xfail*",
|
"*3 skipped*2 xfail*",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_trial_error(self, testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
from twisted.trial.unittest import TestCase
|
||||||
|
from twisted.internet.defer import inlineCallbacks
|
||||||
|
from twisted.internet import reactor
|
||||||
|
|
||||||
|
class TC(TestCase):
|
||||||
|
def test_one(self):
|
||||||
|
crash
|
||||||
|
|
||||||
|
def test_two(self):
|
||||||
|
def f(_):
|
||||||
|
crash
|
||||||
|
|
||||||
|
return reactor.callLater(0.3, f)
|
||||||
|
|
||||||
|
def test_three(self):
|
||||||
|
def f():
|
||||||
|
pass # will never get called
|
||||||
|
return reactor.callLater(0.3, f)
|
||||||
|
# will crash at teardown
|
||||||
|
|
||||||
|
def test_four(self):
|
||||||
|
def f(_):
|
||||||
|
reactor.callLater(0.3, f)
|
||||||
|
crash
|
||||||
|
|
||||||
|
return reactor.callLater(0.3, f)
|
||||||
|
# will crash both at test time and at teardown
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
|
||||||
def test_trial_pdb(self, testdir):
|
def test_trial_pdb(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
|
Loading…
Reference in New Issue