This commit is contained in:
@@ -18,6 +18,14 @@ class FakeAdjustable(Adjustable):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def make_test_id(val):
|
||||||
|
"""Generate readable test IDs"""
|
||||||
|
if not val[1]: # Empty expected list
|
||||||
|
return "empty"
|
||||||
|
if isinstance(val[1][0], str):
|
||||||
|
return val[1][0].lower()
|
||||||
|
return str(val[1][0])
|
||||||
|
|
||||||
@pytest.mark.parametrize("test_input,expected,kwargs", [
|
@pytest.mark.parametrize("test_input,expected,kwargs", [
|
||||||
# Basic functionality
|
# Basic functionality
|
||||||
(
|
(
|
||||||
@@ -62,15 +70,13 @@ class FakeAdjustable(Adjustable):
|
|||||||
["A", "BB", "CCC"],
|
["A", "BB", "CCC"],
|
||||||
{"sort_key": lambda a: len(a.name)}
|
{"sort_key": lambda a: len(a.name)}
|
||||||
)
|
)
|
||||||
], ids=lambda x: x[1][0] if x[1] else "empty")
|
], ids=make_test_id)
|
||||||
def test_snapshot(test_input, expected, kwargs):
|
def test_snapshot(test_input, expected, kwargs):
|
||||||
"""Complete test with proper instance mocking"""
|
"""Complete test with proper instance mocking"""
|
||||||
# Create test objects
|
# Create test objects
|
||||||
test_objects = [FakeAdjustable(*args) for args in test_input]
|
test_objects = [FakeAdjustable(*args) for args in test_input]
|
||||||
|
|
||||||
# Mock the registry system at two levels:
|
# Mock the registry system at two levels:
|
||||||
# 1. The instances() function
|
|
||||||
# 2. The Adjustable._instances class attribute
|
|
||||||
with patch('slic.utils.registry.instances') as mock_instances, \
|
with patch('slic.utils.registry.instances') as mock_instances, \
|
||||||
patch('slic.core.adjustable.Adjustable._instances', new_callable=MagicMock) as mock_adj:
|
patch('slic.core.adjustable.Adjustable._instances', new_callable=MagicMock) as mock_adj:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user