From d75bdff655a1cb076ed08636a3551bdf3c9ba4d7 Mon Sep 17 00:00:00 2001 From: Jim Bosch Date: Fri, 13 Jun 2025 22:05:49 -0400 Subject: [PATCH] Ensure subTest arguments are strings. pytest-xdist chokes on the error messages otherwise, causing the test to fail. --- python/lsst/utils/tests.py | 2 +- tests/test_timer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/lsst/utils/tests.py b/python/lsst/utils/tests.py index 59161a2b..6d832e8f 100644 --- a/python/lsst/utils/tests.py +++ b/python/lsst/utils/tests.py @@ -1014,7 +1014,7 @@ def decorator(func: Callable) -> Callable: def wrapper(self: unittest.TestCase, *args: Any, **kwargs: Any) -> None: for params in _settingsIterator(settings): kwargs.update(params) - with self.subTest(**params): + with self.subTest(**{k: repr(v) for k, v in params.items()}): func(self, *args, **kwargs) return wrapper diff --git a/tests/test_timer.py b/tests/test_timer.py index 17a30049..1cf4ee87 100644 --- a/tests/test_timer.py +++ b/tests/test_timer.py @@ -164,7 +164,7 @@ def testTaskLike(self): duration = 0.1 for log, metadata in parameters: - with self.subTest(log=log, metadata=metadata): + with self.subTest(log=repr(log), metadata=repr(metadata)): task = Example1(log=log, metadata=metadata) self.assertTimer(duration, task) exampleDuration = duration_from_timeMethod(task.metadata, "sleeper")