Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest patterns #403

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading