From f089cd14198b1b3fb9a613cd57aea7b002d75d27 Mon Sep 17 00:00:00 2001 From: tligui_y Date: Wed, 30 Jul 2025 01:42:52 +0200 Subject: [PATCH] Update tests/test_utils_snapshot.py --- tests/test_utils_snapshot.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_utils_snapshot.py b/tests/test_utils_snapshot.py index 1db7fb56..e6f88af4 100644 --- a/tests/test_utils_snapshot.py +++ b/tests/test_utils_snapshot.py @@ -18,6 +18,14 @@ class FakeAdjustable(Adjustable): def __str__(self): 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", [ # Basic functionality ( @@ -62,15 +70,13 @@ class FakeAdjustable(Adjustable): ["A", "BB", "CCC"], {"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): """Complete test with proper instance mocking""" # Create test objects test_objects = [FakeAdjustable(*args) for args in test_input] # 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, \ patch('slic.core.adjustable.Adjustable._instances', new_callable=MagicMock) as mock_adj: