Skip to content

Commit

Permalink
Rewrite tests to avoid Yoda conditions (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogenstad authored Jul 1, 2024
1 parent 03b576a commit 6d9f37b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
]

4 changes: 2 additions & 2 deletions tests/core/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() == {
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 6d9f37b

Please sign in to comment.