diff --git a/tests/instantiation/test_instantiate_explicit_class.py b/tests/instantiation/test_instantiate_explicit_class.py index a98a3094..a2cbe421 100644 --- a/tests/instantiation/test_instantiate_explicit_class.py +++ b/tests/instantiation/test_instantiate_explicit_class.py @@ -10,7 +10,7 @@ class QuamComponentTest(QuamComponent): def test_instantiate_from_class(): - quam_component = QuamComponentTest("hi") + quam_component = QuamComponentTest(str_val="hi") loaded_component = instantiate_quam_class( QuamComponentTest, quam_component.to_dict() ) diff --git a/tests/quam_base/test_quam_dataclass.py b/tests/quam_base/test_quam_dataclass.py index 4435afc2..756975f6 100644 --- a/tests/quam_base/test_quam_dataclass.py +++ b/tests/quam_base/test_quam_dataclass.py @@ -31,7 +31,7 @@ class C: with pytest.raises(TypeError): c = C() - c = C(1) + c = C(int_val=1) assert is_dataclass(c) assert c.int_val == 1 @@ -50,7 +50,7 @@ class C: with pytest.raises(TypeError): c = C() - c = C(2) + c = C(int_val=2) assert is_dataclass(c) assert c.int_val == 2 assert c.int_val_optional == 42 @@ -75,7 +75,7 @@ class DerivedClass(BaseClass): with pytest.raises(TypeError): d = DerivedClass(42) - d = DerivedClass(42, 43) + d = DerivedClass(int_val=42, int_val2=43) f = fields(d) assert len(f) == 2 @@ -94,8 +94,10 @@ class DerivedClass(BaseClass): with pytest.raises(TypeError): d = DerivedClass() + with pytest.raises(TypeError): + d = DerivedClass(int_val2=42) - d = DerivedClass(42) + d = DerivedClass(int_val=42) assert d.int_val == 42 assert d.int_val2 == 43 @@ -104,7 +106,7 @@ class DerivedClass(BaseClass): assert f[0].name == "int_val" assert f[1].name == "int_val2" - d = DerivedClass(42, 44) + d = DerivedClass(int_val=42, int_val2=44) assert d.int_val == 42 assert d.int_val2 == 44 @@ -131,12 +133,18 @@ class DerivedClass(BaseClass): with pytest.raises(TypeError): d = DerivedClass(43) - d = DerivedClass(43, 45) + with pytest.raises(TypeError): + d = DerivedClass(int_val=43) + + with pytest.raises(TypeError): + d = DerivedClass(int_val3=43) + + d = DerivedClass(int_val=43, int_val2=45) assert d.int_val == 43 assert d.int_val2 == 45 assert d.int_val3 == 44 - d = DerivedClass(43, 45, 46) + d = DerivedClass(int_val=43, int_val2=45, int_val3=46) assert d.int_val == 43 assert d.int_val2 == 45 assert d.int_val3 == 46 @@ -187,8 +195,10 @@ class C: assert is_dataclass(C) with pytest.raises(TypeError): c = C() + with pytest.raises(TypeError): + c = C(int_val_optional=42) - c = C(2) + c = C(int_val=2) assert is_dataclass(c) assert c.int_val == 2 assert c.int_val_optional == 42 diff --git a/tests/quam_base/test_to_dict.py b/tests/quam_base/test_to_dict.py index b93b4a78..e882ee7f 100644 --- a/tests/quam_base/test_to_dict.py +++ b/tests/quam_base/test_to_dict.py @@ -14,7 +14,7 @@ class QuamTest(QuamComponent): def test_list_with_component_to_dict(): - c = QuamTest(42) + c = QuamTest(int_val=42) quam_list = QuamList([c]) assert quam_list.to_dict() == [ {"int_val": 42, "__class__": "test_to_dict.QuamTest"} @@ -37,7 +37,7 @@ def test_basic_dict_to_dict(): def test_dict_with_component_to_dict(): - c = QuamTest(42) + c = QuamTest(int_val=42) quam_dict = QuamDict({"a": c}) assert quam_dict.to_dict() == { "a": {"int_val": 42, "__class__": "test_to_dict.QuamTest"} @@ -141,4 +141,4 @@ class QuamBasicComponent(QuamComponent): assert quam_component.to_dict() == {} quam_component = QuamBasicComponent(l=[1, 2, 3]) - assert quam_component.to_dict() == {"l": [1, 2, 3]} \ No newline at end of file + assert quam_component.to_dict() == {"l": [1, 2, 3]} diff --git a/tests/quam_base/test_val_matches_attr_annotation.py b/tests/quam_base/test_val_matches_attr_annotation.py index 401719f8..05223f49 100644 --- a/tests/quam_base/test_val_matches_attr_annotation.py +++ b/tests/quam_base/test_val_matches_attr_annotation.py @@ -9,13 +9,13 @@ class QuamTest(QuamComponent): def test_attr_type_nonexisting(): - test_quam = QuamTest(1, "test") + test_quam = QuamTest(int_val=1, str_val="test") assert not test_quam._val_matches_attr_annotation("nonexisting", None) assert not test_quam._val_matches_attr_annotation("nonexisting", 123) def test_attr_type_basic(): - test_quam = QuamTest(1, "test") + test_quam = QuamTest(int_val=1, str_val="test") assert test_quam._val_matches_attr_annotation("int_val", 1) assert test_quam._val_matches_attr_annotation("str_val", "hi") assert not test_quam._val_matches_attr_annotation("int_val", "hi") @@ -33,7 +33,9 @@ class QuamTest2(QuamComponent): def test_attr_type_dict(): - test_quam = QuamTest2(1, "test", [1, 2, 3], [1, 2, 3], {"a": 1}, {"a": 1}) + test_quam = QuamTest2( + int_val=1, str_val="test", l1=[1, 2, 3], l2=[1, 2, 3], d1={"a": 1}, d2={"a": 1} + ) assert test_quam._val_matches_attr_annotation("d1", {}) assert test_quam._val_matches_attr_annotation("d2", {}) assert not test_quam._val_matches_attr_annotation("d1", 42) @@ -41,7 +43,9 @@ def test_attr_type_dict(): def test_attr_type_list(): - test_quam = QuamTest2(1, "test", [1, 2, 3], [1, 2, 3], {"a": 1}, {"a": 1}) + test_quam = QuamTest2( + int_val=1, str_val="test", l1=[1, 2, 3], l2=[1, 2, 3], d1={"a": 1}, d2={"a": 1} + ) assert test_quam._val_matches_attr_annotation("l1", []) assert test_quam._val_matches_attr_annotation("l2", []) assert not test_quam._val_matches_attr_annotation("l1", 42) diff --git a/tests/quam_base/test_value_annotation.py b/tests/quam_base/test_value_annotation.py index 93376c4b..bd6274c6 100644 --- a/tests/quam_base/test_value_annotation.py +++ b/tests/quam_base/test_value_annotation.py @@ -10,7 +10,7 @@ class TestQuam(QuamComponent): int_val: int str_val: str - test_quam = TestQuam(1, "test") + test_quam = TestQuam(int_val=1, str_val="test") assert _get_value_annotation(test_quam, "nonexisting") is None assert _get_value_annotation(test_quam, "int_val") is None assert _get_value_annotation(test_quam, "str_val") is None @@ -24,7 +24,7 @@ class TestQuam(QuamComponent): d1: dict d2: Dict[str, int] - test_quam = TestQuam(1, "test", {"a": 1}, {"a": 1}) + test_quam = TestQuam(int_val=1, str_val="test", d1={"a": 1}, d2={"a": 1}) assert _get_value_annotation(test_quam, "d1") is None assert _get_value_annotation(test_quam, "str_val") is None assert _get_value_annotation(test_quam, "d2") == int @@ -38,7 +38,7 @@ class TestQuam(QuamComponent): l1: list l2: List[int] - test_quam = TestQuam(1, "test", [1, 2, 3], [1, 2, 3]) + test_quam = TestQuam(int_val=1, str_val="test", l1=[1, 2, 3], l2=[1, 2, 3]) assert _get_value_annotation(test_quam, "l1") is None assert _get_value_annotation(test_quam, "str_val") is None assert _get_value_annotation(test_quam, "l2") == int