Skip to content

Commit

Permalink
Remove test suite warning (#566)
Browse files Browse the repository at this point in the history
**Description of the Change:**

Removes `cannot collect test class 'TestDevice' because it has a
__init__ constructor (from: pytest/test_config_functions.py`, pytest
thinks TestDevice is a class containing test.
  • Loading branch information
rmoyard authored Feb 29, 2024
1 parent 2d0a37f commit 2689a35
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions frontend/test/pytest/test_config_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from catalyst.utils.toml import toml_load


class TestDevice(qml.QubitDevice):
class DummyDevice(qml.QubitDevice):
"""Test device"""

name = "Test Device"
Expand All @@ -54,31 +54,31 @@ def test_toml_file():
config = toml_load(f)
f.close()

name = TestDevice.name
name = DummyDevice.name
with pytest.raises(
CompileError, match=f"Attempting to compile program for incompatible device {name}."
):
check_qjit_compatibility(TestDevice, config)
check_qjit_compatibility(DummyDevice, config)


def test_device_has_config_attr():
"""Test error is raised when device has no config attr."""
name = TestDevice.name
name = DummyDevice.name
msg = f"Attempting to compile program for incompatible device {name}."
with pytest.raises(CompileError, match=msg):
check_device_config(TestDevice)
check_device_config(DummyDevice)


def test_device_with_invalid_config_attr():
"""Test error is raised when device has invalid config attr."""
name = TestDevice.name
name = DummyDevice.name
with tempfile.NamedTemporaryFile(mode="w+b") as f:
f.close()
setattr(TestDevice, "config", Path(f.name))
setattr(DummyDevice, "config", Path(f.name))
msg = f"Attempting to compile program for incompatible device {name}."
with pytest.raises(CompileError, match=msg):
check_device_config(TestDevice)
delattr(TestDevice, "config")
check_device_config(DummyDevice)
delattr(DummyDevice, "config")


def test_get_native_gates():
Expand Down Expand Up @@ -145,3 +145,7 @@ class Device:
msg = f"Gates in qml.device.operations and specification file do not match"
with pytest.raises(CompileError, match=msg):
check_full_overlap(Device(), ["A", "A", "A"], ["B", "B"])


if __name__ == "__main__":
pytest.main([__file__])

0 comments on commit 2689a35

Please sign in to comment.