~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/trial/test/erroneous.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-02-22 22:52:47 UTC
  • Revision ID: james.westby@ubuntu.com-20060222225247-0mjb8ij9473m5zse
Tags: 2.2.0-1ubuntu1
Synchronize with Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
5
 
 
6
 
"""
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
9
 
"""
10
 
 
11
 
#__tests__ = []
12
 
 
13
 
DO_OUTPUT = False
 
4
 
14
5
 
15
6
class FoolishError(Exception):
16
7
    pass
17
8
 
18
9
 
19
 
class TestFailureInSetUp(BaseTest, unittest.TestCase):
 
10
class TestFailureInSetUp(unittest.TestCase):
20
11
    def setUp(self):
21
 
        super(TestFailureInSetUp, self).setUp()
22
12
        raise FoolishError, "I am a broken setUp method"
23
13
 
24
 
 
25
 
class TestFailureInTearDown(BaseTest, unittest.TestCase):
 
14
    def test_noop(self):
 
15
        pass
 
16
 
 
17
 
 
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"
29
21
 
30
 
 
31
 
class TestFailureInSetUpClass(BaseTest, unittest.TestCase):
 
22
    def test_noop(self):
 
23
        pass
 
24
 
 
25
 
 
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"
35
29
 
36
 
 
37
 
class TestFailureInTearDownClass(BaseTest, unittest.TestCase):
 
30
    def test_noop(self):
 
31
        pass
 
32
 
 
33
 
 
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"
41
37
 
42
 
 
43
 
class TestSkipTestCase(BaseTest, unittest.TestCase):
 
38
    def test_noop(self):
 
39
        pass
 
40
 
 
41
 
 
42
class TestRegularFail(unittest.TestCase):
 
43
    def test_fail(self):
 
44
        self.fail("I fail")
 
45
 
 
46
 
 
47
class TestSkipTestCase(unittest.TestCase):
44
48
    pass
45
49
 
46
50
TestSkipTestCase.skip = "skipping this test"
47
51
 
48
52
 
49
 
class TestSkipTestCase2(BaseTest, unittest.TestCase):
 
53
class TestSkipTestCase2(unittest.TestCase):
 
54
    
50
55
    def setUpClass(self):
51
56
        raise unittest.SkipTest, "thi stest is fukct"
52
57
 
53
58
    def test_thisTestWillBeSkipped(self):
54
 
        self.methodCalled = True
55
 
        if DO_OUTPUT:
56
 
            print TESTING_MSG
 
59
        pass
57
60
 
58
61
HIDDEN_EXCEPTION_MSG = "something blew up"
59
62
 
60
 
class DemoTest(BaseTest, unittest.TestCase):
 
63
class DemoTest(unittest.TestCase):
61
64
    def setUp(self):
62
65
        super(DemoTest, self).setUp()
63
66
        self.finished = False
68
71
        self.finished = True
69
72
 
70
73
    def testHiddenException(self):
71
 
        self.methodCalled = True
72
74
        import time
73
75
        cl = reactor.callLater(0, self.go)
74
76
        timeout = time.time() + 2
76
78
            reactor.iterate(0.1)
77
79
        self.failUnless(self.finished)
78
80
 
79
 
class ReactorCleanupTests(BaseTest, unittest.TestCase):
 
81
class ReactorCleanupTests(unittest.TestCase):
80
82
    def test_leftoverPendingCalls(self):
81
 
        self.methodCalled = True
82
83
        def _():
83
84
            print 'foo!'
84
85
        reactor.callLater(10000.0, _)
85
86
 
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)
92
92
 
93
 
class TimingOutDeferred(BaseTest, unittest.TestCase):
 
93
class TimingOutDeferred(unittest.TestCase):
94
94
    def test_alpha(self):
95
95
        pass
96
96
 
101
101
 
102
102
    def test_omega(self):
103
103
        pass
 
104
 
 
105
 
 
106
def unexpectedException(self):
 
107
    """i will raise an unexpected exception...
 
108
    ... *CAUSE THAT'S THE KINDA GUY I AM*
 
109
    
 
110
    >>> 1/0
 
111
    """
 
112