Update tests/test_utils_ipy.py
Run CI Tests / test (push) Successful in 54s

This commit is contained in:
2025-08-03 21:50:51 +02:00
parent 30a5203064
commit 8a314ee05e
+10 -9
View File
@@ -4,19 +4,20 @@ from slic.utils.ipy import devices
from slic.core.device.device import Device
import types
@pytest.fixture(scope="module", autouse=True)
def simulate_ipython(monkeypatch):
# Simulate get_ipython() in pytest environment
# Fixture to simulate an IPython env
@pytest.fixture(scope="module")
def fake_ipython():
class FakeIPython:
def __init__(self):
self.user_ns = {}
return FakeIPython()
fake_ipy = FakeIPython()
monkeypatch.setattr("slic.core.device.devices.get_ipython", lambda: fake_ipy)
return fake_ipy
@pytest.fixture(autouse=True)
def simulate_ipython(fake_ipython, monkeypatch):
monkeypatch.setattr("slic.core.device.devices.get_ipython", lambda: fake_ipython)
return fake_ipython
def test_devices_repr_fallback_and_ignore():
def test_devices_repr_fallback_and_ignore(simulate_ipython):
ipy = simulate_ipython
assert ipy is not None, "This test must be run in IPython (Jupyter or ipython shell)"
@@ -94,4 +95,4 @@ def test_devices_repr_fallback_and_ignore():
"test_str", "test_int", "test_list", "test_func",
"test_module", "test_fake_device", "_test_hidden_device"
]:
assert bad not in out
assert bad not in out