[PATCH] D43024: [test] Enable test category for inline tests.

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 08:28:11 PST 2018


JDevlieghere updated this revision to Diff 133220.
JDevlieghere added a comment.

The change in r324488 dropped the existing category attribute in for
instance methods. This patch corrects that.


https://reviews.llvm.org/D43024

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py


Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -304,13 +304,16 @@
         if isinstance(func, type) and issubclass(func, unittest2.TestCase):
             raise Exception(
                 "@add_test_categories can only be used to decorate a test method")
-        if hasattr(func, "categories"):
-            cat.extend(func.categories)
-        # For instance methods, the attribute must be set on the actual function.
-        if inspect.ismethod(func):
-            func.__func__.categories = cat
-        else:
-            func.categories = cat
+
+        # Update or set the categories attribute. For instance methods, the
+        # attribute must be set on the actual function.
+        func_for_attr = func
+        if inspect.ismethod(func_for_attr):
+            func_for_attr = func.__func__
+        if hasattr(func_for_attr, "categories"):
+            cat.extend(func_for_attr.categories)
+        setattr(func_for_attr, "categories", cat)
+
         return func
 
     return impl


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43024.133220.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180207/d4cbd9c0/attachment.bin>


More information about the llvm-commits mailing list