Rename skip_until to skip_unless
Change-Id: I64c20d6e7b30ade2ee258d5c722f9f895618857c
This commit is contained in:
@@ -58,7 +58,7 @@ MultipleObjectsFound = _select.MultipleObjectsFound
|
|||||||
SkipException = _skip.SkipException
|
SkipException = _skip.SkipException
|
||||||
skip = _skip.skip
|
skip = _skip.skip
|
||||||
skip_if = _skip.skip_if
|
skip_if = _skip.skip_if
|
||||||
skip_until = _skip.skip_until
|
skip_unless = _skip.skip_unless
|
||||||
|
|
||||||
|
|
||||||
from tobiko import config # noqa
|
from tobiko import config # noqa
|
||||||
|
|||||||
@@ -35,13 +35,17 @@ def skip_if(reason, predicate, *args, **kwargs):
|
|||||||
return skip_if_match(reason, bool, predicate, *args, **kwargs)
|
return skip_if_match(reason, bool, predicate, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def skip_until(reason, predicate, *args, **kwargs):
|
def skip_unless(reason, predicate, *args, **kwargs):
|
||||||
return skip_if_match(reason, lambda x: bool(not x), predicate, *args,
|
return skip_if_match(reason, lambda x: bool(not x), predicate, *args,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
|
|
||||||
def skip_if_match(reason, match, predicate, *args, **kwargs):
|
def skip_if_match(reason, match, predicate, *args, **kwargs):
|
||||||
|
|
||||||
|
if not callable(predicate):
|
||||||
|
args = (predicate,) + args
|
||||||
|
predicate = bool
|
||||||
|
|
||||||
def decorator(obj):
|
def decorator(obj):
|
||||||
method = _get_decorated_method(obj)
|
method = _get_decorated_method(obj)
|
||||||
|
|
||||||
|
|||||||
@@ -24,24 +24,24 @@ def condition(value):
|
|||||||
|
|
||||||
class PositiveSkipMethodTest(unit.TobikoUnitTest):
|
class PositiveSkipMethodTest(unit.TobikoUnitTest):
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', True)
|
||||||
condition, True)
|
def test_skip_if_condition(self):
|
||||||
|
self.fail('Not skipped')
|
||||||
|
|
||||||
|
@tobiko.skip_if('condition value was true', condition, True)
|
||||||
def test_skip_if_condition_called_with_args(self):
|
def test_skip_if_condition_called_with_args(self):
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, value=True)
|
||||||
condition, value=True)
|
|
||||||
def test_skip_if_condition_called_with_kwargs(self):
|
def test_skip_if_condition_called_with_kwargs(self):
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, False)
|
||||||
condition, False)
|
def test_skip_unless_condition_called_with_args(self):
|
||||||
def test_skip_until_condition_called_with_args(self):
|
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, value=False)
|
||||||
condition, value=False)
|
def test_skip_unless_condition_called_with_kwargs(self):
|
||||||
def test_skip_until_condition_called_with_kwargs(self):
|
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
|
|
||||||
@@ -58,8 +58,11 @@ class NegativeSkipBase(unit.TobikoUnitTest):
|
|||||||
|
|
||||||
class NegativeSkipMethodTest(NegativeSkipBase):
|
class NegativeSkipMethodTest(NegativeSkipBase):
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was false',
|
@tobiko.skip_if('condition value was false', False)
|
||||||
condition, False)
|
def test_skip_if_conditions(self):
|
||||||
|
self.test_method_called = True
|
||||||
|
|
||||||
|
@tobiko.skip_if('condition value was false', condition, False)
|
||||||
def test_skip_if_condition_called_with_args(self):
|
def test_skip_if_condition_called_with_args(self):
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
@@ -68,38 +71,32 @@ class NegativeSkipMethodTest(NegativeSkipBase):
|
|||||||
def test_skip_if_condition_called_with_kwargs(self):
|
def test_skip_if_condition_called_with_kwargs(self):
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was true',
|
@tobiko.skip_unless('condition value was true', condition, True)
|
||||||
condition, True)
|
def test_skip_unless_condition_called_with_args(self):
|
||||||
def test_skip_until_condition_called_with_args(self):
|
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was true',
|
@tobiko.skip_unless('condition value was true', condition, value=True)
|
||||||
condition, value=True)
|
def test_skip_unless_condition_called_with_kwargs(self):
|
||||||
def test_skip_until_condition_called_with_kwargs(self):
|
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, True)
|
||||||
condition, True)
|
|
||||||
class PositiveSkipIfConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
class PositiveSkipIfConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, value=True)
|
||||||
condition, value=True)
|
|
||||||
class PositiveSkipIfConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
class PositiveSkipIfConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, False)
|
||||||
condition, False)
|
class PositiveSkipUnlessConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
||||||
class PositiveSkipUntilConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, value=False)
|
||||||
condition, value=False)
|
class PositiveSkipUnlessConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
||||||
class PositiveSkipUntilConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -117,40 +114,36 @@ class PositiveSkipFixtureTest(unit.TobikoUnitTest):
|
|||||||
PositiveSkipIfConditionCalledWithKwargsFixture)
|
PositiveSkipIfConditionCalledWithKwargsFixture)
|
||||||
self.assertEqual('condition value was true', str(ex))
|
self.assertEqual('condition value was true', str(ex))
|
||||||
|
|
||||||
def test_skip_until_condition_called_with_args(self):
|
def test_skip_unless_condition_called_with_args(self):
|
||||||
ex = self.assertRaises(
|
ex = self.assertRaises(
|
||||||
self.skipException, tobiko.setup_fixture,
|
self.skipException, tobiko.setup_fixture,
|
||||||
PositiveSkipUntilConditionCalledWithArgsFixture)
|
PositiveSkipUnlessConditionCalledWithArgsFixture)
|
||||||
self.assertEqual('condition value was false', str(ex))
|
self.assertEqual('condition value was false', str(ex))
|
||||||
|
|
||||||
def test_skip_until_condition_called_with_kwargs(self):
|
def test_skip_unless_condition_called_with_kwargs(self):
|
||||||
ex = self.assertRaises(
|
ex = self.assertRaises(
|
||||||
self.skipException, tobiko.setup_fixture,
|
self.skipException, tobiko.setup_fixture,
|
||||||
PositiveSkipUntilConditionCalledWithKwargsFixture)
|
PositiveSkipUnlessConditionCalledWithKwargsFixture)
|
||||||
self.assertEqual('condition value was false', str(ex))
|
self.assertEqual('condition value was false', str(ex))
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was false',
|
@tobiko.skip_if('condition value was false', condition, False)
|
||||||
condition, False)
|
|
||||||
class NegativeSkipIfConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
class NegativeSkipIfConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was false',
|
@tobiko.skip_if('condition value was false', condition, value=False)
|
||||||
condition, value=False)
|
|
||||||
class NegativeSkipIfConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
class NegativeSkipIfConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was true',
|
@tobiko.skip_unless('condition value was true', condition, True)
|
||||||
condition, True)
|
class NegativeSkipUnlessConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
||||||
class NegativeSkipUntilConditionCalledWithArgsFixture(tobiko.SharedFixture):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was true',
|
@tobiko.skip_unless('condition value was true', condition, value=True)
|
||||||
condition, value=True)
|
class NegativeSkipUnlessConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
||||||
class NegativeSkipUntilConditionCalledWithKwargsFixture(tobiko.SharedFixture):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -168,78 +161,70 @@ class NegativeSkipFixtureTest(unit.TobikoUnitTest):
|
|||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
fixture, NegativeSkipIfConditionCalledWithKwargsFixture)
|
fixture, NegativeSkipIfConditionCalledWithKwargsFixture)
|
||||||
|
|
||||||
def test_skip_until_condition_called_with_args(self):
|
def test_skip_unless_condition_called_with_args(self):
|
||||||
fixture = tobiko.setup_fixture(
|
fixture = tobiko.setup_fixture(
|
||||||
NegativeSkipUntilConditionCalledWithArgsFixture)
|
NegativeSkipUnlessConditionCalledWithArgsFixture)
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
fixture, NegativeSkipUntilConditionCalledWithArgsFixture)
|
fixture, NegativeSkipUnlessConditionCalledWithArgsFixture)
|
||||||
|
|
||||||
def test_skip_until_condition_called_with_kwargs(self):
|
def test_skip_unless_condition_called_with_kwargs(self):
|
||||||
fixture = tobiko.setup_fixture(
|
fixture = tobiko.setup_fixture(
|
||||||
NegativeSkipUntilConditionCalledWithKwargsFixture)
|
NegativeSkipUnlessConditionCalledWithKwargsFixture)
|
||||||
self.assertIsInstance(
|
self.assertIsInstance(
|
||||||
fixture, NegativeSkipUntilConditionCalledWithKwargsFixture)
|
fixture, NegativeSkipUnlessConditionCalledWithKwargsFixture)
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, True)
|
||||||
condition, True)
|
|
||||||
class PositiveSkipIfConditionCalledWithArgsTest(unit.TobikoUnitTest):
|
class PositiveSkipIfConditionCalledWithArgsTest(unit.TobikoUnitTest):
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, value=True)
|
||||||
condition, value=True)
|
|
||||||
class PositiveSkipIfConditionCalledWithKwargsTest(unit.TobikoUnitTest):
|
class PositiveSkipIfConditionCalledWithKwargsTest(unit.TobikoUnitTest):
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, False)
|
||||||
condition, False)
|
class PositiveSkipUnlessConditionCalledWithArgsTest(unit.TobikoUnitTest):
|
||||||
class PositiveSkipUntilConditionCalledWithArgsTest(unit.TobikoUnitTest):
|
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, value=False)
|
||||||
condition, value=False)
|
class PositiveSkipUnlessConditionCalledWithKwargsTest(unit.TobikoUnitTest):
|
||||||
class PositiveSkipUntilConditionCalledWithKwargsTest(unit.TobikoUnitTest):
|
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.fail('Not skipped')
|
self.fail('Not skipped')
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, False)
|
||||||
condition, False)
|
|
||||||
class NegativeSkipIfConditionCalledWithArgsTest(NegativeSkipBase):
|
class NegativeSkipIfConditionCalledWithArgsTest(NegativeSkipBase):
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_if('condition value was true',
|
@tobiko.skip_if('condition value was true', condition, value=False)
|
||||||
condition, value=False)
|
|
||||||
class NegativeSkipIfConditionCalledWithKwargsTest(NegativeSkipBase):
|
class NegativeSkipIfConditionCalledWithKwargsTest(NegativeSkipBase):
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, True)
|
||||||
condition, True)
|
class NegativeSkipUnlessConditionCalledWithArgsTest(NegativeSkipBase):
|
||||||
class NegativeSkipUntilConditionCalledWithArgsTest(NegativeSkipBase):
|
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|
||||||
|
|
||||||
@tobiko.skip_until('condition value was false',
|
@tobiko.skip_unless('condition value was false', condition, value=True)
|
||||||
condition, value=True)
|
class NegativeSkipUnlessConditionCalledWithKwargsTest(NegativeSkipBase):
|
||||||
class NegativeSkipUntilConditionCalledWithKwargsTest(NegativeSkipBase):
|
|
||||||
|
|
||||||
def test_fail(self):
|
def test_fail(self):
|
||||||
self.test_method_called = True
|
self.test_method_called = True
|
||||||
|
|||||||
Reference in New Issue
Block a user