Skip to content

Commit

Permalink
Merge pull request #26 from SweepMe/import_driver_test
Browse files Browse the repository at this point in the history
Update test for driver import
  • Loading branch information
franz-sweepMe authored Jan 17, 2024
2 parents eca25ec + 86a67ba commit e01c7a5
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/importability/import_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ def is_compatible(driver_name: str) -> bool:
return False


# Driver name and reason for skipping
SKIPPED_DRIVERS = {
"Logger-MCC_DAQ": "Driver requires installed manufacturer software",
}


def should_skip_driver(driver_name: str) -> bool:
"""Check if the driver can be tested on a virtual machine.
Args:
driver_name: Name (folder) of the driver to import.
"""
if SKIPPED_DRIVERS.get(driver_name) is not None:
logging.debug(
f"Skipped importing {driver_name}. Reason: {SKIPPED_DRIVERS[driver_name]}",
)
return True

return False


def import_driver(driver_name: str) -> None:
"""Let pysweepme import a driver from the src directory.
Expand Down Expand Up @@ -90,9 +111,11 @@ def import_driver(driver_name: str) -> None:
msg = "This script must be called with the driver name as first argument."
raise IndexError(msg) from e

if is_compatible(driver_name):
import_driver(driver_name)
else:
if not is_compatible(driver_name):
logging.debug(
f"Skipped importing {driver_name} because it is not meant to be compatible with this python version.",
)
elif should_skip_driver(driver_name):
pass
else:
import_driver(driver_name)

0 comments on commit e01c7a5

Please # to comment.