[Lldb-commits] [lldb] r324492 - [test] Don't drop existing categories for methods.
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 7 09:34:46 PST 2018
Author: jdevlieghere
Date: Wed Feb 7 09:34:46 2018
New Revision: 324492
URL: http://llvm.org/viewvc/llvm-project?rev=324492&view=rev
Log:
[test] Don't drop existing categories for methods.
The change in r324488 dropped the existing category attribute in for
instance methods. This patch corrects that.
Differential revision: https://reviews.llvm.org/D43024
Modified:
lldb/trunk/packages/Python/lldbsuite/test/decorators.py
Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=324492&r1=324491&r2=324492&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Wed Feb 7 09:34:46 2018
@@ -304,13 +304,16 @@ def add_test_categories(cat):
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
More information about the lldb-commits
mailing list