diff --git a/tests/test_parallel.py b/tests/test_parallel.py index 098d246b4..105302872 100644 --- a/tests/test_parallel.py +++ b/tests/test_parallel.py @@ -41,6 +41,11 @@ def interactive(f): TRAVIS = os.getenv('TRAVIS', False) SKIP_PARALLEL = TRAVIS +if os.getenv('WERCKER_REDIS_URL', False): + REDIS_HOST = 'localhost' +else: + REDIS_HOST = os.getenv('WERCKER_REDIS_URL').split('//')[1].split(':')[0] + @interactive def to_the_power_of_2_interactive(arg): return arg ** 2 @@ -94,11 +99,11 @@ def test_length(self): class TestRedisQueue(unittest.TestCase): def test_queue_size(self): - queue = RedisQueue("test-queue-size-1", maxsize=1, host=os.getenv('WERCKER_REDIS_HOST', 'localhost')) + queue = RedisQueue("test-queue-size-1", maxsize=1, host=REDIS_HOST) queue.put(1) self.assertRaises(six.moves.queue.Full, queue.put, 1) - queue = RedisQueue("test-queue-size-2", maxsize=2, host=os.getenv('WERCKER_REDIS_HOST', 'localhost')) + queue = RedisQueue("test-queue-size-2", maxsize=2, host=REDIS_HOST) queue.put(1) queue.put(1) self.assertRaises(six.moves.queue.Full, queue.put, 1) @@ -107,7 +112,7 @@ def test_queue_size(self): self.assertRaises(six.moves.queue.Empty, queue.get_nowait) def test_queue_objects(self): - queue = RedisQueue("test-queue", maxsize=100, host=os.getenv('WERCKER_REDIS_HOST', 'localhost')) + queue = RedisQueue("test-queue", maxsize=100, host=REDIS_HOST) # put int queue.put(1) v = queue.get_nowait() @@ -140,7 +145,7 @@ def test_queue_objects(self): self.assertIsInstance(v, dict) def test_queue_len(self): - queue = RedisQueue("test-queue-len", maxsize=100, host=os.getenv('WERCKER_REDIS_HOST', 'localhost')) + queue = RedisQueue("test-queue-len", maxsize=100, host=REDIS_HOST) self.assertEqual(queue.length, 0) queue.put(1) self.assertEqual(queue.length, 1) diff --git a/tests/test_strain_design_heuristics.py b/tests/test_strain_design_heuristics.py index b5f097a40..bdaf5dcbd 100644 --- a/tests/test_strain_design_heuristics.py +++ b/tests/test_strain_design_heuristics.py @@ -50,6 +50,11 @@ TRAVIS = os.getenv('TRAVIS', False) +if os.getenv('WERCKER_REDIS_URL', False): + REDIS_HOST = 'localhost' +else: + REDIS_HOST = os.getenv('WERCKER_REDIS_URL').split('//')[1].split(':')[0] + SEED = 1234 CURRENT_PATH = os.path.dirname(__file__) @@ -594,21 +599,21 @@ def setUp(self): unittest.skipIf(os.getenv('WERCKER', False), 'Currently not working on wercker as redis is not running on localhost') def test_migrator_constructor(self): - migrator = MultiprocessingMigrator(max_migrants=1) + migrator = MultiprocessingMigrator(max_migrants=1, host=REDIS_HOST) self.assertIsInstance(migrator.migrants, RedisQueue) self.assertEqual(migrator.max_migrants, 1) - migrator = MultiprocessingMigrator(max_migrants=2) + migrator = MultiprocessingMigrator(max_migrants=2, host=REDIS_HOST) self.assertIsInstance(migrator.migrants, RedisQueue) self.assertEqual(migrator.max_migrants, 2) - migrator = MultiprocessingMigrator(max_migrants=3) + migrator = MultiprocessingMigrator(max_migrants=3, host=REDIS_HOST) self.assertIsInstance(migrator.migrants, RedisQueue) self.assertEqual(migrator.max_migrants, 3) unittest.skipIf(os.getenv('WERCKER', False), 'Currently not working on wercker as redis is not running on localhost') def test_migrate_individuals_without_evaluation(self): - migrator = MultiprocessingMigrator(max_migrants=1) + migrator = MultiprocessingMigrator(max_migrants=1, host=REDIS_HOST) self.assertIsInstance(migrator.migrants, RedisQueue) self.assertEqual(migrator.max_migrants, 1)