Skip to content

Commit

Permalink
Make test gathering more deterministic to avoid failures
Browse files Browse the repository at this point in the history
  • Loading branch information
samdoran committed Nov 4, 2022
1 parent 91e1283 commit f7406da
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/unit/plugins/lookup/onepassword/test_onepassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,20 @@ def test_op_get_field(mocker, op_fixture, output, expected, request):
assert result == expected


# This test sometimes fails on older Python versions because the gathered tests mismatch.
# Attempt to make this more reliable by creating deterministic IDs
# https://github.com/pytest-dev/pytest-xdist/issues/432
@pytest.mark.parametrize(
("cli_class", "vault", "queries", "kwargs", "output", "expected"),
(
(_cli_class, item["vault_name"], item["queries"], item.get("kwargs", {}), item["output"], item["expected"])
for _cli_class in MOCK_ENTRIES
for item in MOCK_ENTRIES[_cli_class]
),
ids=[
f"v{cls.supports_version}_{idx + 1}" for cls in MOCK_ENTRIES
for idx, value in enumerate(MOCK_ENTRIES[cls])
],
)
def test_op_lookup(mocker, cli_class, vault, queries, kwargs, output, expected):
mocker.patch("ansible_collections.community.general.plugins.lookup.onepassword.OnePass._get_cli_class", cli_class)
Expand Down

0 comments on commit f7406da

Please sign in to comment.