forked from OSchip/llvm-project
[testsuite] Remove workaround for categories and inline tests.
Adding categories to inline tests does not work because the attribute is set at the function level. For methods, this means it applies to all instances of that particular class. While this is what we want in most cases, it's not for inline tests, where different instances correspond to different tests. With the workaround in place, assigning a category to one test resulted in the category applied to *all* inline tests. This patch removes the workaround and throws an exception with an informative error message, to prevent this from happening in the future. llvm-svn: 326552
This commit is contained in:
parent
2373516cad
commit
3a9d431386
|
@ -304,15 +304,12 @@ 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")
|
||||
|
||||
# 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)
|
||||
try:
|
||||
if hasattr(func, "categories"):
|
||||
cat.extend(func.categories)
|
||||
setattr(func, "categories", cat)
|
||||
except AttributeError:
|
||||
raise Exception('Cannot assign categories to inline tests.')
|
||||
|
||||
return func
|
||||
|
||||
|
|
Loading…
Reference in New Issue