Browse Source

Merge "test cleanup: Remove skipIf test decorator"

changes/81/669181/12
Zuul 2 weeks ago
parent
commit
72a3013e76
1 changed files with 0 additions and 32 deletions
  1. +0
    -32
      nova/test.py

+ 0
- 32
nova/test.py View File

@@ -122,38 +122,6 @@ class TestingException(Exception):
pass


class skipIf(object):
def __init__(self, condition, reason):
self.condition = condition
self.reason = reason

def __call__(self, func_or_cls):
condition = self.condition
reason = self.reason
if inspect.isfunction(func_or_cls):
@six.wraps(func_or_cls)
def wrapped(*args, **kwargs):
if condition:
raise testtools.TestCase.skipException(reason)
return func_or_cls(*args, **kwargs)

return wrapped
elif inspect.isclass(func_or_cls):
orig_func = getattr(func_or_cls, 'setUp')

@six.wraps(orig_func)
def new_func(self, *args, **kwargs):
if condition:
raise testtools.TestCase.skipException(reason)
orig_func(self, *args, **kwargs)

func_or_cls.setUp = new_func
return func_or_cls
else:
raise TypeError('skipUnless can be used only with functions or '
'classes')


# NOTE(claudiub): this needs to be called before any mock.patch calls are
# being done, and especially before any other test classes load. This fixes
# the mock.patch autospec issue:

Loading…
Cancel
Save