Skip to content

Commit

Permalink
Do not skip tests via exception during test collection
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Mar 14, 2024
1 parent 570ae79 commit d311b69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import warnings

try:
import tabor_control
except ImportError as err:
raise unittest.SkipTest("tabor_control not present") from err

from tests.hardware.tabor_simulator_based_tests import TaborSimulatorManager
from tests.hardware.tabor_simulator_based_tests import TaborSimulatorManager
except ImportError:
TaborSimulatorManager = None
from tests.hardware.dummy_devices import DummyDAC
from tests.backward_compatibility.hardware_test_helper import LoadingAndSequencingHelper

Expand Down Expand Up @@ -102,6 +100,7 @@ def read_program(self):
return self.program_AB, self.program_CD


@unittest.skipIf(tabor_control is None, "tabor_control not available")
class CompleteIntegrationTestHelper(unittest.TestCase):
data_folder = None
pulse_name = None
Expand Down
14 changes: 9 additions & 5 deletions tests/hardware/tabor_simulator_based_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
try:
import pyvisa.resources
import tabor_control
except ImportError as err:
raise unittest.SkipTest("pyvisa and/or tabor_control not present") from err
except ImportError:
tabor_control = None
pyvisa = None

import numpy as np

from qupulse.hardware.awgs.tabor import TaborAWGRepresentation, TaborChannelPair
try:
from qupulse.hardware.awgs.tabor import TaborAWGRepresentation, TaborChannelPair
except ImportError:
pass
from qupulse._program.tabor import TaborSegment, PlottableProgram, TaborException, TableDescription, TableEntry
from typing import List, Tuple, Optional, Any

Expand Down Expand Up @@ -48,7 +52,7 @@ def kill_running_simulators(self):
def simulator_full_path(self):
return os.path.join(self.simulator_path, self.simulator_executable)

def start_simulator(self, try_connecting_to_existing_simulator=True, max_wait_time=30) -> pyvisa.resources.MessageBasedResource:
def start_simulator(self, try_connecting_to_existing_simulator=True, max_wait_time=30) -> 'pyvisa.resources.MessageBasedResource':
try:
pyvisa.ResourceManager()
except ValueError:
Expand Down Expand Up @@ -95,7 +99,7 @@ def __del__(self):
self.simulator_process.kill()


@unittest.skipIf(platform.system() != 'Windows', "Simulator currently only available on Windows :(")
@unittest.skipIf(tabor_control is None or platform.system() != 'Windows', "Simulator currently only available on Windows :(")
class TaborSimulatorBasedTest(unittest.TestCase):
simulator_manager = None

Expand Down

0 comments on commit d311b69

Please sign in to comment.