summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-02-07 17:34:46 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-02-07 17:34:46 +0000
commitea6fbd92d8a4913957de9b7f1799abdead64f9fc (patch)
tree343c4349f1501cf0d5fd7ee5abb4556f93bd7888 /lldb/packages/Python/lldbsuite/test
parentefed656873be88d303d1702a100b4304db490026 (diff)
downloadbcm5719-llvm-ea6fbd92d8a4913957de9b7f1799abdead64f9fc.tar.gz
bcm5719-llvm-ea6fbd92d8a4913957de9b7f1799abdead64f9fc.zip
[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 llvm-svn: 324492
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/decorators.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 4248c461c88..f0afa9aea84 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -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
OpenPOWER on IntegriCloud