Skip to content

Commit

Permalink
Properly handle missing keys in the configuration for the pytest salt…
Browse files Browse the repository at this point in the history
… logging handler.

Fixes #101

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
  • Loading branch information
s0undt3ch committed Feb 17, 2022
1 parent bdf228f commit fedc5ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/101.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Properly handle missing keys in the configuration for the pytest salt logging handler.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def __virtual__():
role = __opts__["__role"]
pytest_key = "pytest-{}".format(role)

if pytest_key not in __opts__ and "pytest" not in __opts__:
return False, "Neither '{}' nor 'pytest' keys in opts dictionary".format(pytest_key)

if pytest_key not in __opts__:
pytest_key = "pytest"

pytest_config = __opts__[pytest_key]
if "log" not in pytest_config:
return False, "No 'log' key in opts {} dictionary".format(pytest_key)
Expand Down

0 comments on commit fedc5ed

Please sign in to comment.