Skip to content

Commit ee6e531

Browse files
committed
test_device_server: do sleep after start process in setUp instead of each test.
1 parent df67ef2 commit ee6e531

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

microscope/testsuite/test_device_server.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def setUp(self):
113113
target=microscope.device_server.serve_devices, args=(self.DEVICES,)
114114
)
115115
self.p.start()
116+
time.sleep(1)
116117

117118
def tearDown(self):
118119
self.p.terminate()
@@ -138,6 +139,7 @@ def setUp(self):
138139
self.queue = multiprocessing.Queue()
139140
self.process = DeviceServerExceptionQueue(self.queue, *self.args)
140141
self.process.start()
142+
time.sleep(1)
141143

142144
def tearDown(self):
143145
self.process.terminate()
@@ -159,7 +161,6 @@ class TestStarting(BaseTestServeDevices):
159161

160162
def test_standard(self):
161163
"""Simplest case, start and exit, given enough time to start all devices"""
162-
time.sleep(2)
163164
self.assertTrue(self.p.is_alive(), "service dies at start")
164165

165166
def test_immediate_interrupt(self):
@@ -170,7 +171,6 @@ def test_immediate_interrupt(self):
170171
class TestInputCheck(BaseTestServeDevices):
171172
def test_empty_devices(self):
172173
"""Check behaviour if there are no devices."""
173-
time.sleep(2)
174174
self.assertTrue(
175175
not self.p.is_alive(), "not dying for empty list of devices"
176176
)
@@ -199,7 +199,6 @@ class TestClashingArguments(BaseTestServeDevices):
199199
]
200200

201201
def test_port_conflict(self):
202-
time.sleep(2)
203202
client = microscope.clients.Client(
204203
"PYRO:DeviceWithPort@127.0.0.1:8000"
205204
)
@@ -244,7 +243,6 @@ class TestFloatingDeviceIndexInjection(BaseTestServeDevices):
244243
]
245244

246245
def test_injection_of_index_kwarg(self):
247-
time.sleep(1)
248246
floating_1 = Pyro4.Proxy("PYRO:TestFloatingDevice@127.0.0.1:8001")
249247
floating_2 = Pyro4.Proxy("PYRO:TestFloatingDevice@127.0.0.1:8002")
250248
self.assertEqual(floating_1.get_index(), 0)
@@ -275,7 +273,6 @@ class TestServingFloatingDevicesWithWrongUID(BaseTestDeviceServer):
275273

276274
def test_fail_with_wrong_uid(self):
277275
"""DeviceServer fails if it gets a FloatingDevice with another UID """
278-
time.sleep(1)
279276
self.assertFalse(
280277
self.process.is_alive(),
281278
"expected DeviceServer to have errored and be dead",
@@ -305,7 +302,6 @@ class TestFunctionInDeviceDefinition(BaseTestDeviceServer):
305302

306303
def test_function_in_device_definition(self):
307304
"""Function that constructs multiple devices in device definition"""
308-
time.sleep(1)
309305
self.assertTrue(self.process.is_alive())
310306
dm1 = Pyro4.Proxy("PYRO:dm1@127.0.0.1:8001")
311307
dm2 = Pyro4.Proxy("PYRO:dm2@127.0.0.1:8001")
@@ -325,7 +321,6 @@ class TestKeepDeviceServerAlive(BaseTestServeDevices):
325321
"can't test if we can't kill subprocess (windows)",
326322
)
327323
def test_keep_alive(self):
328-
time.sleep(2)
329324
device = Pyro4.Proxy("PYRO:ExposePIDDevice@127.0.0.1:8001")
330325
initial_pid = device.get_pid()
331326

0 commit comments

Comments
 (0)