Add decorator to skip tests if TOBIKO_PREVENT_CREATE is True

Change-Id: I238791c8f0eb90bc161cb63ba114c3d2785a94a7
This commit is contained in:
Federico Ressi 2021-09-02 15:11:28 +02:00
parent 36c7cfd07c
commit 7499bccc62
2 changed files with 10 additions and 5 deletions

View File

@ -378,3 +378,12 @@ def get_list_env(name, separator=','):
return value.split(separator)
else:
return []
def is_prevent_create() -> bool:
return get_bool_env('TOBIKO_PREVENT_CREATE') is True
def skip_if_prevent_create(reason='TOBIKO_PREVENT_CREATE is True'):
return tobiko.skip_if(reason=reason,
predicate=is_prevent_create)

View File

@ -48,13 +48,9 @@ class ServerStackResourcesTest(testtools.TestCase):
self.assertEqual(port.physical_resource_id, port_data['id'])
@config.skip_if_prevent_create()
class ServerCreationTest(testtools.TestCase):
def setUp(self):
testtools.TestCase.setUp(self)
if config.get_bool_env('TOBIKO_PREVENT_CREATE'):
self.skip('TOBIKO_PREVENT_CREATE is true')
def test_server_creation(self):
tests.test_server_creation()