This commit is contained in:
@@ -4,19 +4,20 @@ from slic.utils.ipy import devices
|
|||||||
from slic.core.device.device import Device
|
from slic.core.device.device import Device
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
# Fixture to simulate an IPython env
|
||||||
@pytest.fixture(scope="module", autouse=True)
|
@pytest.fixture(scope="module")
|
||||||
def simulate_ipython(monkeypatch):
|
def fake_ipython():
|
||||||
# Simulate get_ipython() in pytest environment
|
|
||||||
class FakeIPython:
|
class FakeIPython:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.user_ns = {}
|
self.user_ns = {}
|
||||||
|
return FakeIPython()
|
||||||
|
|
||||||
fake_ipy = FakeIPython()
|
@pytest.fixture(autouse=True)
|
||||||
monkeypatch.setattr("slic.core.device.devices.get_ipython", lambda: fake_ipy)
|
def simulate_ipython(fake_ipython, monkeypatch):
|
||||||
return fake_ipy
|
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
|
ipy = simulate_ipython
|
||||||
assert ipy is not None, "This test must be run in IPython (Jupyter or ipython shell)"
|
assert ipy is not None, "This test must be run in IPython (Jupyter or ipython shell)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user