~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/fixtures.py

  • Committer: Patch Queue Manager
  • Date: 2015-12-17 18:39:00 UTC
  • mfrom: (6606.1.2 fix-float)
  • Revision ID: pqm@pqm.ubuntu.com-20151217183900-0719du2uv1kwu3lc
(vila) Inline testtools private method to fix an issue in xenial (the
 private implementation has changed in an backward incompatible way).
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
    testcase.build_tree_contents([('t/hello', 'hello world')])
139
139
    tree.add(['hello'], ['hello-id'])
140
140
    return tree
 
141
 
 
142
 
 
143
class TimeoutFixture(object):
 
144
    """Kill a test with sigalarm if it runs too long.
 
145
    
 
146
    Only works on Unix at present.
 
147
    """
 
148
 
 
149
    def __init__(self, timeout_secs):
 
150
        import signal
 
151
        self.timeout_secs = timeout_secs
 
152
        self.alarm_fn = getattr(signal, 'alarm', None)
 
153
 
 
154
    def setUp(self):
 
155
        if self.alarm_fn is not None:
 
156
            self.alarm_fn(self.timeout_secs)
 
157
 
 
158
    def cleanUp(self):
 
159
        if self.alarm_fn is not None:
 
160
            self.alarm_fn(0)