diff options
author | Julien Danjou <julien@danjou.info> | 2014-12-02 15:30:05 +0100 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2014-12-02 15:32:31 +0100 |
commit | 39c09eda6033556072f80701afa1e6d720e366ca (patch) | |
tree | daff62177ada246a48f2a5fadfa7dc8db6b8c9c9 | |
parent | 007e02cf06444ab6c4c5ea12f5fceb4fd4a31472 (diff) | |
download | tooz-39c09eda6033556072f80701afa1e6d720e366ca.tar.gz |
tests: use scenarios attributes for timeout capability
Change-Id: I78931eca9478289e5c643ce37364e059d8009728
-rw-r--r-- | tooz/tests/test_coordination.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/tooz/tests/test_coordination.py b/tooz/tests/test_coordination.py index 0890256..d1a1993 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) |