This commit is contained in:
+12
-8
@@ -5,15 +5,19 @@ from slic.core.device.device import Device
|
||||
import types
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def simulate_ipython(monkeypatch):
|
||||
@pytest.fixture(scope="module")
|
||||
def fake_ipython():
|
||||
"""Fixture module-scoped pour simuler IPython"""
|
||||
class FakeIPython:
|
||||
def __init__(self):
|
||||
self.user_ns = {}
|
||||
return FakeIPython()
|
||||
|
||||
fake_ipy = FakeIPython()
|
||||
monkeypatch.setattr("slic.utils.ipy.get_ipython", lambda: fake_ipy)
|
||||
return fake_ipy
|
||||
@pytest.fixture(autouse=True)
|
||||
def simulate_ipython(fake_ipython, monkeypatch):
|
||||
"""Configure le mock IPython avant chaque test"""
|
||||
monkeypatch.setattr("slic.utils.ipy.get_ipython", lambda: fake_ipython)
|
||||
return fake_ipython
|
||||
|
||||
def test_devices_repr_fallback_and_ignore(simulate_ipython):
|
||||
ipy = simulate_ipython
|
||||
@@ -30,7 +34,7 @@ def test_devices_repr_fallback_and_ignore(simulate_ipython):
|
||||
super().__init__(ID)
|
||||
self.ID = ID
|
||||
self.description = "desc ok"
|
||||
self.name = None # Explicit None
|
||||
self.name = None
|
||||
|
||||
class WithDoc(Device):
|
||||
"""doc ok"""
|
||||
@@ -69,7 +73,7 @@ def test_devices_repr_fallback_and_ignore(simulate_ipython):
|
||||
|
||||
out = repr(devices)
|
||||
|
||||
# Core assertions (unchanged)
|
||||
# Core assertions
|
||||
assert "test_desc" in out
|
||||
assert "desc ok" in out
|
||||
assert "test_doc" in out
|
||||
@@ -81,7 +85,7 @@ def test_devices_repr_fallback_and_ignore(simulate_ipython):
|
||||
assert "test_str" not in out
|
||||
assert "_hidden" not in out
|
||||
|
||||
# New None checks (what you asked for)
|
||||
# None checks
|
||||
assert getattr(ipy.user_ns["test_desc"], "name") is None
|
||||
assert getattr(ipy.user_ns["test_doc"], "name") is None
|
||||
assert getattr(ipy.user_ns["test_doc"], "description") is None
|
||||
|
||||
Reference in New Issue
Block a user