1
# -*- test-case-name: twisted.trial.test.test_trial -*-
1
# -*- test-case-name: twisted.trial.test.test_tests -*-
2
2
from twisted.trial import unittest
3
3
from twisted.internet import reactor, protocol, defer
4
from twisted.trial.test.common import BaseTest
7
in some cases, it is necessary to run trial in a child process to effectively test it's behavior
8
in erroneous conditions, this module provides such tests
15
6
class FoolishError(Exception):
19
class TestFailureInSetUp(BaseTest, unittest.TestCase):
10
class TestFailureInSetUp(unittest.TestCase):
21
super(TestFailureInSetUp, self).setUp()
22
12
raise FoolishError, "I am a broken setUp method"
25
class TestFailureInTearDown(BaseTest, unittest.TestCase):
18
class TestFailureInTearDown(unittest.TestCase):
26
19
def tearDown(self):
27
super(TestFailureInTearDown, self).tearDown()
28
20
raise FoolishError, "I am a broken tearDown method"
31
class TestFailureInSetUpClass(BaseTest, unittest.TestCase):
26
class TestFailureInSetUpClass(unittest.TestCase):
32
27
def setUpClass(self):
33
super(TestFailureInSetUpClass, self).setUpClass()
34
28
raise FoolishError, "I am a broken setUpClass method"
37
class TestFailureInTearDownClass(BaseTest, unittest.TestCase):
34
class TestFailureInTearDownClass(unittest.TestCase):
38
35
def tearDownClass(self):
39
super(TestFailureInTearDownClass, self).tearDownClass()
40
36
raise FoolishError, "I am a broken setUp method"
43
class TestSkipTestCase(BaseTest, unittest.TestCase):
42
class TestRegularFail(unittest.TestCase):
47
class TestSkipTestCase(unittest.TestCase):
46
50
TestSkipTestCase.skip = "skipping this test"
49
class TestSkipTestCase2(BaseTest, unittest.TestCase):
53
class TestSkipTestCase2(unittest.TestCase):
50
55
def setUpClass(self):
51
56
raise unittest.SkipTest, "thi stest is fukct"
53
58
def test_thisTestWillBeSkipped(self):
54
self.methodCalled = True
58
61
HIDDEN_EXCEPTION_MSG = "something blew up"
60
class DemoTest(BaseTest, unittest.TestCase):
63
class DemoTest(unittest.TestCase):
62
65
super(DemoTest, self).setUp()
63
66
self.finished = False
76
78
reactor.iterate(0.1)
77
79
self.failUnless(self.finished)
79
class ReactorCleanupTests(BaseTest, unittest.TestCase):
81
class ReactorCleanupTests(unittest.TestCase):
80
82
def test_leftoverPendingCalls(self):
81
self.methodCalled = True
84
85
reactor.callLater(10000.0, _)
86
class SocketOpenTest(BaseTest, unittest.TestCase):
87
class SocketOpenTest(unittest.TestCase):
87
88
def test_socketsLeftOpen(self):
88
self.methodCalled = True
89
89
f = protocol.Factory()
90
90
f.protocol = protocol.Protocol
91
91
reactor.listenTCP(0, f)
93
class TimingOutDeferred(BaseTest, unittest.TestCase):
93
class TimingOutDeferred(unittest.TestCase):
94
94
def test_alpha(self):