From 42950ea06dc8f9a3b42b3b248499a5e73ad68699 Mon Sep 17 00:00:00 2001 From: Chad Stryker Date: Tue, 16 Jun 2020 07:28:49 -0700 Subject: [PATCH] Added a clear() in highlevel.py to prevent the NotImplementedError raised by the base class method. Added a test function to verify the fix. --- pyvisa-sim/highlevel.py | 4 ++++ pyvisa-sim/testsuite/test_all.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/pyvisa-sim/highlevel.py b/pyvisa-sim/highlevel.py index d745391..27725d9 100644 --- a/pyvisa-sim/highlevel.py +++ b/pyvisa-sim/highlevel.py @@ -255,3 +255,7 @@ def disable_event(self, session, event_type, mechanism): def discard_events(self, session, event_type, mechanism): # TODO: implement this for GPIB finalization pass + + def clear(self, session): + # Override to prevent the base class from raising a NotImplementedError + pass diff --git a/pyvisa-sim/testsuite/test_all.py b/pyvisa-sim/testsuite/test_all.py index 190d4fe..8a67f42 100644 --- a/pyvisa-sim/testsuite/test_all.py +++ b/pyvisa-sim/testsuite/test_all.py @@ -35,6 +35,17 @@ def test_list(resource_manager): } +@pytest.mark.parametrize('resource', [ + 'ASRL1::INSTR', +]) +def test_clear(resource, resource_manager): + inst = resource_manager.open_resource(resource, read_termination='\n', + write_termination='\r\n' if resource.startswith('ASRL') else '\n') + + inst.clear() + inst.close() + + @pytest.mark.parametrize('resource', [ 'ASRL1::INSTR', 'GPIB0::8::0::INSTR',