Skip to content

Commit

Permalink
run black on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrijapau committed Dec 24, 2024
1 parent 50573f1 commit 353056b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ruff
pylint
black
isort
pre-commit
18 changes: 12 additions & 6 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def test_api_key_not_found_error(self, monkeypatch, tmpdir):
monkeypatch.setattr("os.curdir", tmpdir.join("folder_without_a_config_file"))

monkeypatch.setattr(
"pennylane.default_config", qml.Configuration("config.toml"),
"pennylane.default_config",
qml.Configuration("config.toml"),
) # force loading of config
with pytest.raises(ValueError, match="No valid api key for AQT platform found"):
AQTDevice(2)
Expand Down Expand Up @@ -222,7 +223,8 @@ def test_apply_operation_S(self, wires):

@pytest.mark.parametrize("wires", [[0], [1], [2]])
@pytest.mark.parametrize(
("op", "aqt_name"), [(qml.PauliX, "X"), (qml.PauliY, "Y"), (qml.PauliZ, "Z")],
("op", "aqt_name"),
[(qml.PauliX, "X"), (qml.PauliY, "Y"), (qml.PauliZ, "Z")],
)
def test_apply_operation_pauli(self, wires, op, aqt_name):
"""Tests that the _apply_operation method correctly populates the circuit
Expand Down Expand Up @@ -438,7 +440,8 @@ def test_api_key_not_found_error(self, monkeypatch, tmpdir):
monkeypatch.setattr("os.curdir", tmpdir.join("folder_without_a_config_file"))

monkeypatch.setattr(
"pennylane.default_config", qml.Configuration("config.toml"),
"pennylane.default_config",
qml.Configuration("config.toml"),
) # force loading of config
with pytest.raises(ValueError, match="No valid api key for AQT platform found"):
qml.device("aqt.sim", 2)
Expand All @@ -451,7 +454,8 @@ def test_device_gets_local_config(self, monkeypatch, tmpdir):
tmpdir.join("config.toml").write(test_config)
monkeypatch.setattr("os.curdir", tmpdir)
monkeypatch.setattr(
"pennylane.default_config", qml.Configuration("config.toml"),
"pennylane.default_config",
qml.Configuration("config.toml"),
) # force loading of config

dev = qml.device("aqt.sim", wires=2)
Expand All @@ -470,7 +474,8 @@ def test_device_gets_api_key_default_config_directory(self, monkeypatch, tmpdir)
config_dir = tmpdir.mkdir("pennylane") # fake default config directory
config_dir.join("config.toml").write(test_config)
monkeypatch.setenv(
"XDG_CONFIG_HOME", os.path.expanduser(tmpdir),
"XDG_CONFIG_HOME",
os.path.expanduser(tmpdir),
) # HACK: only works on linux

monkeypatch.setattr("os.curdir", tmpdir.join("folder_without_a_config_file"))
Expand All @@ -495,7 +500,8 @@ def test_device_gets_api_key_pennylane_conf_env_var(self, monkeypatch, tmpdir):

monkeypatch.setattr("os.curdir", tmpdir.join("folder_without_a_config_file"))
monkeypatch.setattr(
"pennylane.default_config", qml.Configuration("config.toml"),
"pennylane.default_config",
qml.Configuration("config.toml"),
) # force loading of config

dev = qml.device("aqt.sim", wires=2)
Expand Down

0 comments on commit 353056b

Please sign in to comment.