From 0425df3d1902378c6b63dda1c8eb1b10eafec73b Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Tue, 16 Oct 2018 21:22:43 -0400 Subject: [PATCH] Use fixture for CSRF-enabled app We don't want CSRF protection to stick around after the test runs. --- tests/routes/test_errors.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/routes/test_errors.py b/tests/routes/test_errors.py index e4d316cf..2ab85918 100644 --- a/tests/routes/test_errors.py +++ b/tests/routes/test_errors.py @@ -1,6 +1,14 @@ -def test_csrf_error(app, client): - app.config.update({"WTF_CSRF_ENABLED": True}) +import pytest + +@pytest.fixture +def csrf_enabled_app(app): + app.config.update({"WTF_CSRF_ENABLED": True}) + yield app + app.config.update({"WTF_CSRF_ENABLED": False}) + + +def test_csrf_error(csrf_enabled_app, client): response = client.post( "/requests/new/1", headers={"Content-Type": "application/x-www-form-urlencoded"},