From 3025032c52d336e9dd80ee3049ca2669af419fa0 2014-03-28 18:45:46 From: MinRK Date: 2014-03-28 18:45:46 Subject: [PATCH] make spin_thread tests more forgiving of slow VMs test metadata directly and increase timeouts --- diff --git a/IPython/parallel/tests/test_client.py b/IPython/parallel/tests/test_client.py index 11d7480..06aefd3 100644 --- a/IPython/parallel/tests/test_client.py +++ b/IPython/parallel/tests/test_client.py @@ -522,19 +522,23 @@ class TestClient(ClusterTestCase): def test_spin_thread(self): self.client.spin_thread(0.01) ar = self.client[-1].apply_async(lambda : 1) - time.sleep(0.1) - self.assertTrue(ar.wall_time < 0.1, - "spin should have kept wall_time < 0.1, but got %f" % ar.wall_time - ) + md = self.client.metadata[ar.msg_ids[0]] + # 3s timeout, 100ms poll + for i in range(30): + time.sleep(0.1) + if md['received'] is not None: + break + self.assertIsInstance(md['received'], datetime) def test_stop_spin_thread(self): self.client.spin_thread(0.01) self.client.stop_spin_thread() ar = self.client[-1].apply_async(lambda : 1) - time.sleep(0.15) - self.assertTrue(ar.wall_time > 0.1, - "Shouldn't be spinning, but got wall_time=%f" % ar.wall_time - ) + md = self.client.metadata[ar.msg_ids[0]] + # 500ms timeout, 100ms poll + for i in range(5): + time.sleep(0.1) + self.assertIsNone(md['received'], None) def test_activate(self): ip = get_ipython()