From eaa9f50f66c607cb3ad69da46bfecb9c2e3a4e76 Mon Sep 17 00:00:00 2001 From: Christian Theune Date: Sat, 18 Nov 2023 19:00:05 +0100 Subject: [PATCH] try out pytest-patterns --- setup.py | 1 + src/batou/tests/test_endtoend.py | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index acc9b604..e213dddb 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ "pytest-coverage", "pytest-instafail", "pytest-timeout", + "pytest-patterns", ] }, entry_points=""" diff --git a/src/batou/tests/test_endtoend.py b/src/batou/tests/test_endtoend.py index 4e8341c9..dc3a0a3d 100644 --- a/src/batou/tests/test_endtoend.py +++ b/src/batou/tests/test_endtoend.py @@ -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("") + patterns.gpg.optional( + """ +gpg: ... +..."...<...@...>" +""" + ) + + errors = patterns.errors + errors.merge("gpg", "empty_lines") + errors.in_order( + """ batou/2... (cpython 3...) ================================== Preparing =================================== main: Loading environment `errors`... @@ -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) @@ -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():