From 44b6777291bba5f0071433def89091931ddbffb0 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 7 Nov 2016 11:57:08 +0100 Subject: [PATCH] Fix compatibility with newer pytest versions --- src/pretix/testutils/mock.py | 7 ++++++- src/tests/control/test_user.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pretix/testutils/mock.py b/src/pretix/testutils/mock.py index 21dd60ca5..c506c7d54 100644 --- a/src/pretix/testutils/mock.py +++ b/src/pretix/testutils/mock.py @@ -3,8 +3,13 @@ from contextlib import contextmanager from pytest_mock import MockFixture +class FakePytestConfig: + def getini(self, *args, **kwargs): + return 'False' + + @contextmanager def mocker_context(): - result = MockFixture() + result = MockFixture(FakePytestConfig()) yield result result.stopall() diff --git a/src/tests/control/test_user.py b/src/tests/control/test_user.py index 8eec35eff..9e914da57 100644 --- a/src/tests/control/test_user.py +++ b/src/tests/control/test_user.py @@ -1,6 +1,6 @@ import time -from _pytest import monkeypatch +import pytest from django_otp.oath import TOTP from django_otp.plugins.otp_static.models import StaticDevice from django_otp.plugins.otp_totp.models import TOTPDevice @@ -115,6 +115,12 @@ class UserSettingsTest(SoupTest): assert self.user.password == pw +@pytest.fixture +def class_monkeypatch(request, monkeypatch): + request.cls.monkeypatch = monkeypatch + + +@pytest.mark.usefixtures("class_monkeypatch") class UserSettings2FATest(SoupTest): def setUp(self): super().setUp() @@ -261,7 +267,7 @@ class UserSettings2FATest(SoupTest): 'name': 'Foo' }, follow=True) - m = monkeypatch.monkeypatch() + m = self.monkeypatch m.setattr("u2flib_server.u2f.complete_register", lambda *args, **kwargs: (JSONDict({}), None)) d = U2FDevice.objects.first()