mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Inline our code with what unittest.case.skip
does
This commit is contained in:
parent
ca4e3c5e93
commit
1e16375702
1 changed files with 13 additions and 10 deletions
|
@ -175,11 +175,8 @@ def expensiveTest(caller):
|
|||
def slowTest(caller):
|
||||
"""
|
||||
Mark a test case as a slow test.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class MyTestCase(TestCase):
|
||||
|
||||
@slowTest
|
||||
def test_that_takes_much_time(self):
|
||||
pass
|
||||
|
@ -190,14 +187,20 @@ def slowTest(caller):
|
|||
if RUNTIME_VARS.PYTEST_SESSION:
|
||||
setattr(caller, "__slow_test__", True)
|
||||
|
||||
# We're simply decorating functions
|
||||
@functools.wraps(caller)
|
||||
def wrap(cls, *args, **kwargs):
|
||||
if os.environ.get("SLOW_TESTS", "False").lower() == "false":
|
||||
raise SkipTest("Slow tests are disabled")
|
||||
return caller(cls, *args, **kwargs)
|
||||
if os.environ.get("SLOW_TESTS", "False").lower() == "false":
|
||||
reason = "Slow tests are disabled"
|
||||
|
||||
return wrap
|
||||
if not isinstance(caller, type):
|
||||
|
||||
@functools.wraps(caller)
|
||||
def skip_wrapper(*args, **kwargs):
|
||||
raise SkipTest(reason)
|
||||
|
||||
caller = skip_wrapper
|
||||
|
||||
caller.__unittest_skip__ = True
|
||||
caller.__unittest_skip_why__ = reason
|
||||
return caller
|
||||
|
||||
|
||||
def flaky(caller=None, condition=True, attempts=4):
|
||||
|
|
Loading…
Add table
Reference in a new issue