From 39c09eda6033556072f80701afa1e6d720e366ca Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 2 Dec 2014 15:30:05 +0100 Subject: [PATCH] tests: use scenarios attributes for timeout capability Change-Id: I78931eca9478289e5c643ce37364e059d8009728 --- tooz/tests/test_coordination.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tooz/tests/test_coordination.py b/tooz/tests/test_coordination.py index 08902561..d1a1993f 100644 --- a/tooz/tests/test_coordination.py +++ b/tooz/tests/test_coordination.py @@ -33,23 +33,18 @@ class TestAPI(testscenarios.TestWithScenarios, 'bad_url': 'kazoo://localhost:1'}), ('zake', {'url': 'zake://?timeout=5'}), ('memcached', {'url': os.getenv("TOOZ_TEST_MEMCACHED_URL"), - 'bad_url': 'memcached://localhost:1'}), + 'bad_url': 'memcached://localhost:1', + 'timeout_capable': True}), ('ipc', {'url': 'ipc://'}), ('redis', {'url': os.getenv("TOOZ_TEST_REDIS_URL"), - 'bad_url': 'redis://localhost:1'}), + 'bad_url': 'redis://localhost:1', + 'timeout_capable': True}), ('postgresql', {'url': os.getenv("TOOZ_TEST_PGSQL_URL"), 'bad_url': 'postgresql://localhost:1'}), ('mysql', {'url': os.getenv("TOOZ_TEST_MYSQL_URL"), 'bad_url': 'mysql://localhost:1'}), ] - # Only certain drivers have the tested support for timeouts that we test - # here, these are the lists of driver types that do support our test type. - timeout_capable = [ - 'memcached://', - 'redis://', - ] - def assertRaisesAny(self, exc_classes, callable_obj, *args, **kwargs): checkers = [matchers.MatchesException(exc_class) for exc_class in exc_classes] @@ -57,16 +52,6 @@ class TestAPI(testscenarios.TestWithScenarios, callable_obj = testcase.Nullary(callable_obj, *args, **kwargs) self.assertThat(callable_obj, matcher) - def skipIfNotSupported(self, supported): - applicable = False - for prefix in supported: - if self.url.startswith(prefix): - applicable = True - break - if not applicable: - self.skipTest("This test only works with %s types for now" - % list(supported)) - def setUp(self): super(TestAPI, self).setUp() if self.url is None: @@ -246,7 +231,8 @@ class TestAPI(testscenarios.TestWithScenarios, self.assertTrue(member_id_test2 not in members_ids) def test_timeout(self): - self.skipIfNotSupported(self.timeout_capable) + if not getattr(self, "timeout_capable", False): + self.skipTest("This test only works with timeout capable drivers") member_id_test2 = self._get_random_uuid() client2 = tooz.coordination.get_coordinator(self.url, member_id_test2)