From f1c02012a2a604d0e26feee963f1b3cf7c2387eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 1 Oct 2022 13:06:43 +0200 Subject: [PATCH] Made instruction representation tests more independant --- tests/test_instruction.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/test_instruction.py b/tests/test_instruction.py index 1d9dd92..56516dc 100644 --- a/tests/test_instruction.py +++ b/tests/test_instruction.py @@ -30,13 +30,26 @@ def instr(): ) +# ------------------------------------------------------------------------------ + + +def test_default_repr_instruction_only(instr: _Instruction): + """Default representation returns action followed by ``()``.""" + rv = instr.repr_instruction_only() + assert rv == _INSTR_REPR + + class TestRepr: """Tests for the ``__repr__`` method.""" - def test_default_repr_instruction_only(self, instr: _Instruction): - """Default representation returns action followed by ``()``.""" - rv = instr.repr_instruction_only() - assert rv == _INSTR_REPR + @pytest.fixture + def instr(self): + """Create a mock instruction suitable for testing.""" + instr = _Instruction( + mock.MagicMock(), mock.MagicMock(), mock.MagicMock(), _ACTION_NAME + ) + instr.repr_instruction_only = mock.MagicMock(return_value=_INSTR_REPR) + return instr def test_repr_no_flow(self, instr: _Instruction): """``repr()`` returns default representation if there is no flow \