This commit is contained in:
+10
-9
@@ -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
|
||||
Reference in New Issue
Block a user