Skip to content

Commit 1e84daa

Browse files
authored
Merge pull request #7643 from jenshnielsen/make_driver_test_generic
Make DriverTestCase generic
2 parents 8817ba7 + 39edafd commit 1e84daa

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/qcodes/extensions/_driver_test_case.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import unittest
4-
from typing import TYPE_CHECKING
4+
from typing import TYPE_CHECKING, Generic, TypeVar
55

66
if TYPE_CHECKING:
77
from qcodes.instrument import Instrument
@@ -25,10 +25,13 @@
2525
"""
2626

2727

28-
class DriverTestCase(unittest.TestCase):
28+
T = TypeVar("T", bound="Instrument")
29+
30+
31+
class DriverTestCase(unittest.TestCase, Generic[T]):
2932
# override this in a subclass
30-
driver: type[Instrument] | None = None
31-
instrument: Instrument
33+
driver: type[T] | None = None
34+
instrument: T
3235

3336
@classmethod
3437
def setUpClass(cls) -> None:

tests/drivers/test_Agilent_E8257D.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from qcodes.instrument_drivers.agilent import AgilentE8257D
33

44

5-
class TestAgilentE8257D(DriverTestCase):
5+
class TestAgilentE8257D(DriverTestCase[AgilentE8257D]):
66
"""
77
This is a test suite for testing the QuTech_ControlBox Instrument.
88
It is designed to provide a test function for each function as well as for

tests/drivers/test_weinchel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from qcodes.instrument_drivers.weinschel import Weinschel8320
33

44

5-
class TestWeinschel8320(DriverTestCase):
5+
class TestWeinschel8320(DriverTestCase[Weinschel8320]):
66
"""
77
This is a test suite for testing the weinschel/aeroflex stepped attenuator.
88
It is designed to provide a test function for each function as well as for

0 commit comments

Comments
 (0)