From 6d9f37bd42142339dc36958c8b96b8ac02bfbbdc Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Mon, 1 Jul 2024 09:13:20 +0200 Subject: [PATCH] Rewrite tests to avoid Yoda conditions (#955) --- pyproject.toml | 1 - tests/core/test_inventory.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aeb52315..0f917d55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -259,6 +259,5 @@ max-returns = 11 "PT018", # Assertion should be broken down into multiple parts "PT011", # `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception "SIM118", # Use `key in dict` instead of `key in dict.keys()` - "SIM300", # Yoda conditions are discouraged ] diff --git a/tests/core/test_inventory.py b/tests/core/test_inventory.py index 4f9563d1..6219b6e5 100644 --- a/tests/core/test_inventory.py +++ b/tests/core/test_inventory.py @@ -65,7 +65,7 @@ def test_inventory_data(self, inv): assert "blah" in h.values() assert "my_var" in h.keys() assert "only_default" in h.keys() - assert "comes_from_dev1.group_1" == dict(h.items())["my_var"] + assert dict(h.items())["my_var"] == "comes_from_dev1.group_1" def test_inventory_dict(self, inv): assert inv.dict() == { @@ -561,7 +561,7 @@ def test_add_group(self): assert inv.groups["g3"].defaults.connection_options.get("username") == "test_user" assert inv.groups["g3"].defaults.connection_options.get("password") == "test_pass" assert "test_var" in inv.groups["g3"].defaults.data.keys() - assert "test_value" == inv.groups["g3"].defaults.data.get("test_var") + assert inv.groups["g3"].defaults.data.get("test_var") == "test_value" assert inv.groups["g3"].connection_options["netmiko"].extras["device_type"] == "cisco_ios" def test_dict(self, inv):