A test for trial

This commit is contained in:
Maciej Fijalkowski 2010-11-24 14:54:56 +02:00
parent 9be1cd8007
commit 233baecd2d
2 changed files with 36 additions and 2 deletions

View File

@ -1,6 +1,6 @@
""" discovery and running of std-library "unittest" style tests. """
import pytest, py
import sys
import sys, pdb
def pytest_pycollect_makeitem(collector, name, obj):
unittest = sys.modules.get('unittest')
@ -96,7 +96,9 @@ def pytest_runtest_protocol(item, __multicall__):
if exc_value is None:
self._rawexcinfo = sys.exc_info()
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)
ut.Failure.__init__ = excstore
try:

View File

@ -225,6 +225,38 @@ class TestTrialUnittest:
"*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):
p = testdir.makepyfile("""
from twisted.trial import unittest