From 3926d2c95682e886019de2d3743924ae7fd65daa Mon Sep 17 00:00:00 2001
From: Anton Joubert <ajoubert@ska.ac.za>
Date: Thu, 27 May 2021 08:08:40 +0200
Subject: [PATCH] [SAR-227] Use fixture for debugger port patch

---
 tests/test_base_device.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/test_base_device.py b/tests/test_base_device.py
index 6ea95ef6..c98de267 100644
--- a/tests/test_base_device.py
+++ b/tests/test_base_device.py
@@ -618,21 +618,22 @@ class TestSKABaseDevice(object):
             s.connect(("localhost", _DEBUGGER_PORT))
         assert tango_context.device.state
 
+    @pytest.mark.usefixtures("patch_debugger_to_start_on_ephemeral_port")
     def test_DebugDevice_twice_does_not_raise(self, tango_context):
-        patch_debugger_to_start_on_ephermal_port()
         tango_context.device.DebugDevice()
         tango_context.device.DebugDevice()
         assert SKABaseDevice._global_debugger_listening
 
+    @pytest.mark.usefixtures("patch_debugger_to_start_on_ephemeral_port")
     def test_DebugDevice_does_not_break_a_command(self, tango_context):
-        patch_debugger_to_start_on_ephermal_port()
         tango_context.device.DebugDevice()
         assert tango_context.device.State() == DevState.OFF
         tango_context.device.On()
         assert tango_context.device.State() == DevState.ON
 
 
-def patch_debugger_to_start_on_ephermal_port():
+@pytest.fixture()
+def patch_debugger_to_start_on_ephemeral_port():
     ska_tango_base.base.base_device._DEBUGGER_PORT = 0
 
 
-- 
GitLab