diff --git a/tangostationcontrol/tangostationcontrol/integration_test/device_proxy.py b/tangostationcontrol/tangostationcontrol/integration_test/device_proxy.py index 00ba0904c7bd01fa2ce1453a4c6701d6a4246e14..b0085d9646a9cb0208108bbcabb263a3173e54ef 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/device_proxy.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/device_proxy.py @@ -1,3 +1,5 @@ +import time + from tango import DeviceProxy @@ -6,3 +8,15 @@ class TestDeviceProxy(DeviceProxy): def __init__(self, *args, **kwargs): super(TestDeviceProxy, self).__init__(*args, **kwargs) self.set_timeout_millis(10000) + + @staticmethod + def test_device_turn_off(endpoint): + d = TestDeviceProxy(endpoint) + try: + d.Off() + except Exception as e: + """Failing to turn Off devices should not raise errors here""" + print(f"Failed to turn device off in teardown {e}") + + """Wait for 1 second to prevent propagating reconnection errors""" + time.sleep(1) diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_recv.py b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_recv.py index 6d9353936537a116442409b9ce7c343fa4d803b1..bbb5cab66163f0f76c201d424c8ad5460abe2dfb 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_recv.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_recv.py @@ -7,6 +7,8 @@ # Distributed under the terms of the APACHE license. # See LICENSE.txt for more info. +import time + from tango._tango import DevState from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy @@ -18,15 +20,7 @@ class TestDeviceRECV(base.IntegrationTestCase): def setUp(self): super(TestDeviceRECV, self).setUp() - def tearDown(self): - """Turn device Off in teardown to prevent blocking tests""" - d = TestDeviceProxy("STAT/RECV/1") - - try: - d.Off() - except Exception as e: - """Failing to turn Off devices should not raise errors here""" - print(f"Failed to turn device off in teardown {e}") + self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/RECV/1") def test_device_proxy_recv(self): """Test if we can successfully create a DeviceProxy and fetch state""" diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sdp.py b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sdp.py index f12fc0ae4f9094c6c82a2dd9076f49cea7fd7ef1..669b64ae1f4ed1ebf56670e89cc3d01c3e86dd7e 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sdp.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sdp.py @@ -7,7 +7,8 @@ # Distributed under the terms of the APACHE license. # See LICENSE.txt for more info. -from tango import DeviceProxy +import time + from tango._tango import DevState from tangostationcontrol.integration_test.device_proxy import TestDeviceProxy @@ -20,15 +21,7 @@ class TestDeviceSDP(base.IntegrationTestCase): """Intentionally recreate the device object in each test""" super(TestDeviceSDP, self).setUp() - def tearDown(self): - """Turn device Off in teardown to prevent blocking tests""" - d = TestDeviceProxy("STAT/SDP/1") - - try: - d.Off() - except Exception as e: - """Failing to turn Off devices should not raise errors here""" - print(f"Failed to turn device off in teardown {e}") + self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/SDP/1") def test_device_proxy_sdp(self): """Test if we can successfully create a DeviceProxy and fetch state""" diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sst.py b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sst.py index 210dc93defc98c51f9fb9a2b0497a52e5547e5a7..0dc4579d7fc9a4a57b024433201898a3521e4682 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sst.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_sst.py @@ -22,15 +22,7 @@ class TestDeviceSST(base.IntegrationTestCase): """Intentionally recreate the device object in each test""" super(TestDeviceSST, self).setUp() - def tearDown(self): - """Turn device Off in teardown to prevent blocking tests""" - d = TestDeviceProxy("STAT/SST/1") - - try: - d.Off() - except Exception as e: - """Failing to turn Off devices should not raise errors here""" - print(f"Failed to turn device off in teardown {e}") + self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/SST/1") def test_device_proxy_sst(self): """Test if we can successfully create a DeviceProxy and fetch state""" diff --git a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_unb2.py b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_unb2.py index 4a0382f2aea7c370562ff4d23e37c85c7963a436..09c62c5e0d1b757536f8f1f39e041935c2c0e7e6 100644 --- a/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_unb2.py +++ b/tangostationcontrol/tangostationcontrol/integration_test/devices/test_device_unb2.py @@ -19,15 +19,7 @@ class TestDeviceUNB2(base.IntegrationTestCase): """Intentionally recreate the device object in each test""" super(TestDeviceUNB2, self).setUp() - def tearDown(self): - """Turn device Off in teardown to prevent blocking tests""" - d = TestDeviceProxy("STAT/UNB2/1") - - try: - d.Off() - except Exception as e: - """Failing to turn Off devices should not raise errors here""" - print(f"Failed to turn device off in teardown {e}") + self.addCleanup(TestDeviceProxy.test_device_turn_off, "STAT/UNB2/1") def test_device_proxy_unb2(self): """Test if we can successfully create a DeviceProxy and fetch state"""