~certify-web-dev/twisted/certify-staging

« back to all changes in this revision

Viewing changes to twisted/test/test_rebuild.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-01-02 19:38:17 UTC
  • mfrom: (2.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100102193817-jphp464ppwh7dulg
Tags: 9.0.0-1
* python-twisted: Depend on the python-twisted-* 9.0 packages.
* python-twisted: Depend on python-zope.interface only. Closes: #557781.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2001-2007 Twisted Matrix Laboratories.
 
1
# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
2
2
# See LICENSE for details.
3
3
 
4
4
 
16
16
class Baz(object): pass
17
17
class Buz(Bar, Baz): pass
18
18
 
 
19
class HashRaisesRuntimeError:
 
20
    """
 
21
    Things that don't hash (raise an Exception) should be ignored by the
 
22
    rebuilder.
 
23
 
 
24
    @ivar hashCalled: C{bool} set to True when __hash__ is called.
 
25
    """
 
26
    def __init__(self):
 
27
        self.hashCalled = False
 
28
 
 
29
    def __hash__(self):
 
30
        self.hashCalled = True
 
31
        raise RuntimeError('not a TypeError!')
 
32
 
 
33
 
 
34
 
 
35
unhashableObject = None # set in test_hashException
 
36
 
 
37
 
 
38
 
19
39
class RebuildTestCase(unittest.TestCase):
20
40
    """
21
41
    Simple testcase for rebuilding, to at least exercise the code.
126
146
        rebuild.latestClass(banana.Banana)
127
147
 
128
148
 
 
149
    def test_hashException(self):
 
150
        """
 
151
        Rebuilding something that has a __hash__ that raises a non-TypeError
 
152
        shouldn't cause rebuild to die.
 
153
        """
 
154
        global unhashableObject
 
155
        unhashableObject = HashRaisesRuntimeError()
 
156
        def _cleanup():
 
157
            global unhashableObject
 
158
            unhashableObject = None
 
159
        self.addCleanup(_cleanup)
 
160
        rebuild.rebuild(rebuild)
 
161
        self.assertEquals(unhashableObject.hashCalled, True)
 
162
 
 
163
 
129
164
 
130
165
class NewStyleTestCase(unittest.TestCase):
131
166
    """