summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Holman <bholman.devel@gmail.com>2021-12-07 13:36:23 -0700
committerGitHub <noreply@github.com>2021-12-07 14:36:23 -0600
commitb21afb0a8ab64543715dffff490253db8ecefb9f (patch)
treeef1f09a845cab0c586f8c7bade0e0fa6b3f469e8
parent2969ceaa6447774f921fe7dd06a39c175e87e45c (diff)
downloadcloud-init-git-b21afb0a8ab64543715dffff490253db8ecefb9f.tar.gz
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.
-rw-r--r--tests/unittests/test_util.py8
1 files changed, 7 insertions, 1 deletions
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:<YAML>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.