Skip to content

Commit

Permalink
try out pytest-patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ctheune committed Nov 29, 2023
1 parent 279a014 commit eaa9f50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"pytest-coverage",
"pytest-instafail",
"pytest-timeout",
"pytest-patterns",
]
},
entry_points="""
Expand Down
25 changes: 19 additions & 6 deletions src/batou/tests/test_endtoend.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,23 @@ def test_example_errors_early():
) # noqa: E501 line too long


def test_example_errors_gpg_cannot_decrypt(monkeypatch):
def test_example_errors_gpg_cannot_decrypt(monkeypatch, patterns):
monkeypatch.setitem(os.environ, "GNUPGHOME", "")
os.chdir("examples/errors")
out, _ = cmd("./batou deploy errors", acceptable_returncodes=[1])
assert out == Ellipsis(
"""\

patterns.empty_lines.optional("<empty-line>")
patterns.gpg.optional(
"""
gpg: ...
..."...<...@...>"
"""
)

errors = patterns.errors
errors.merge("gpg", "empty_lines")
errors.in_order(
"""
batou/2... (cpython 3...)
================================== Preparing ===================================
main: Loading environment `errors`...
Expand All @@ -72,8 +83,8 @@ def test_example_errors_gpg_cannot_decrypt(monkeypatch):
command: gpg --decrypt ...environments/errors/secrets.cfg.gpg
exit code: 2
message:
gpg: ...
...
gpg: encrypted ...
ERROR: Failed loading component file
File: .../examples/errors/components/component5/component.py
Exception: invalid syntax (component.py, line 1)
Expand All @@ -92,7 +103,9 @@ def test_example_errors_gpg_cannot_decrypt(monkeypatch):
Component: nonexisting-component-section
======================= DEPLOYMENT FAILED (during load) ========================
"""
) # noqa: E501 line too long
)

assert errors == out


def test_example_errors_late():
Expand Down

0 comments on commit eaa9f50

Please sign in to comment.