From b79086e6a9cc9f47fa27fe57a9ebe4b6a3928d59 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 22 Mar 2017 15:18:39 +0100 Subject: [PATCH] tests: make a fixture of EmailsMocking (fixes #15555) --- tests/conftest.py | 8 ++++++++ tests/test_backoffice_pages.py | 6 +++--- tests/test_form_pages.py | 7 +++---- tests/test_register.py | 8 ++++---- tests/test_workflows.py | 8 ++++---- tests/utilities.py | 25 +++++++++++++++++-------- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 31d4d3c..424e68e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,8 @@ import ConfigParser import pytest +from utilities import EmailsMocking + def pytest_addoption(parser): parser.addoption('--without-postgresql-tests', action='store_true', @@ -49,3 +51,9 @@ def fargo_secret(request, pub): @pytest.fixture def welco_url(request, pub): return site_options(request, pub, 'options', 'welco_url', 'http://welco.example.net') + + +@pytest.fixture +def emails(): + with EmailsMocking() as mock: + yield mock diff --git a/tests/test_backoffice_pages.py b/tests/test_backoffice_pages.py index bc3c239..56abdd8 100644 --- a/tests/test_backoffice_pages.py +++ b/tests/test_backoffice_pages.py @@ -32,7 +32,8 @@ from wcs.formdef import FormDef from wcs import fields from utilities import (get_app, login, create_temporary_pub, - clean_temporary_pub, emails, sms_mocking) + clean_temporary_pub, sms_mocking) + def pytest_generate_tests(metafunc): if 'pub' in metafunc.fixturenames: @@ -2787,12 +2788,11 @@ def test_360_user_view(pub): resp = app.get('/backoffice/management/users/%s/' % user.id) assert resp.body.count('