← Back to team overview

testtools-dev team mailing list archive

Re: [Merge] lp:~jml/testtools/less-stack into lp:testtools

 

Review: Approve

+* ``AfterPreproccessing`` renamed to ``AfterPreproccesing``, which is a more
+  correct spelling.  Old name preserved for backwards compatibility, but is
+  now deprecated.  Please stop using it.
+  (Jonathan Lange, #813460)

Typo ?
Do you want one s or one c. The code wants one c.


155	+def safe_hasattr(obj, attr):
...
162	+    marker = object()
163	+    return getattr(obj, attr, marker) is not marker
164	

Can I suggest

155	+def safe_hasattr(obj, attr, marker=object()):
...
162	+    return getattr(obj, attr, marker) is not marker

This is a microoptimisation, but for a potentially inner loop call.

You might prefer FunctionFixture here:

330	+class StackHidingFixture(Fixture):
331	+
332	+    def __init__(self, should_hide):
333	+        super(StackHidingFixture, self).__init__()
334	+        self._should_hide = should_hide
335	+
336	+    def setUp(self):
337	+        super(StackHidingFixture, self).setUp()
338	+        self.addCleanup(hide_testtools_stack, is_stack_hidden())
339	+        hide_testtools_stack(self._should_hide)

->

+def hide_testtools_stack(should_hide=True):
+    modules = [
+        'testtools.matchers',
+        'testtools.runtest',
+        'testtools.testcase',
+        ]
+    result = is_stack_hidden()
+    for module_name in modules:
+        module = try_import(module_name)
+        if should_hide:
+            setattr(module, '__unittest', True)
+        else:
+            try:
+                delattr(module, '__unittest')
+            except AttributeError:
+                # Attribute already doesn't exist. Our work here is done.
+                pass
+    return result
+
+ StackHidingFixture = FunctionFixture(hide_testtools_stack, hide_testtools_stack)

-- 
https://code.launchpad.net/~jml/testtools/less-stack/+merge/68543
Your team testtools developers is subscribed to branch lp:testtools.


References