~lifeless/debian/sid/testresources/packaging

« back to all changes in this revision

Viewing changes to debian/patches/crash-in-teardown.patch

  • Committer: Robert Collins
  • Date: 2009-09-20 07:19:49 UTC
  • mfrom: (40.1.1 testresources)
  • Revision ID: robertc@robertcollins.net-20090920071949-y2ee4havrud27g9m
Convert CDBS patch to merge from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -Nur -x '*.orig' -x '*~' testresources-0.2/lib/testresources/__init__.py testresources-0.2.new/lib/testresources/__init__.py
2
 
--- testresources-0.2/lib/testresources/__init__.py     2009-07-17 13:20:26.000000000 +0100
3
 
+++ testresources-0.2.new/lib/testresources/__init__.py 2009-08-05 23:38:21.000000000 +0100
4
 
@@ -374,7 +374,12 @@
5
 
         stack = inspect.stack()
6
 
         for frame in stack[3:]:
7
 
             if frame[3] in ('run', '__call__'):
8
 
-                return frame[0].f_locals['result']
9
 
+                # Not all frames called 'run' will be unittest. It could be a
10
 
+                # reactor in trial, for instance.
11
 
+                result = frame[0].f_locals.get('result')
12
 
+                if (result is not None and
13
 
+                    getattr(result, 'startTest', None) is not None):
14
 
+                    return result
15
 
 
16
 
     def setUp(self):
17
 
         unittest.TestCase.setUp(self)