From b21afb0a8ab64543715dffff490253db8ecefb9f Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Tue, 7 Dec 2021 13:36:23 -0700 Subject: testing: Add deterministic test id (#1138) Parametrized pytest tests get named by on their parameters. If a name has random characters, it can break the test collection of when using pytest-xdist. Replace random name with deterministic name. --- tests/unittests/test_util.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 3b76ead8..eab374bc 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -1010,11 +1010,17 @@ class TestIsLXD(CiTestCase): class TestReadCcFromCmdline: + if hasattr(pytest, "param"): + random_string = pytest.param( + CiTestCase.random_string(), None, id="random_string") + else: + random_string = (CiTestCase.random_string(), None) + @pytest.mark.parametrize( "cmdline,expected_cfg", [ # Return None if cmdline has no cc:end_cc content. - (CiTestCase.random_string(), None), + random_string, # Return None if YAML content is empty string. ('foo cc: end_cc bar', None), # Return expected dictionary without trailing end_cc marker. -- cgit v1.2.3