forked from CGM_Public/pretix_original
Fix compatibility with newer pytest versions
This commit is contained in:
@@ -3,8 +3,13 @@ from contextlib import contextmanager
|
|||||||
from pytest_mock import MockFixture
|
from pytest_mock import MockFixture
|
||||||
|
|
||||||
|
|
||||||
|
class FakePytestConfig:
|
||||||
|
def getini(self, *args, **kwargs):
|
||||||
|
return 'False'
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def mocker_context():
|
def mocker_context():
|
||||||
result = MockFixture()
|
result = MockFixture(FakePytestConfig())
|
||||||
yield result
|
yield result
|
||||||
result.stopall()
|
result.stopall()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from _pytest import monkeypatch
|
import pytest
|
||||||
from django_otp.oath import TOTP
|
from django_otp.oath import TOTP
|
||||||
from django_otp.plugins.otp_static.models import StaticDevice
|
from django_otp.plugins.otp_static.models import StaticDevice
|
||||||
from django_otp.plugins.otp_totp.models import TOTPDevice
|
from django_otp.plugins.otp_totp.models import TOTPDevice
|
||||||
@@ -115,6 +115,12 @@ class UserSettingsTest(SoupTest):
|
|||||||
assert self.user.password == pw
|
assert self.user.password == pw
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def class_monkeypatch(request, monkeypatch):
|
||||||
|
request.cls.monkeypatch = monkeypatch
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("class_monkeypatch")
|
||||||
class UserSettings2FATest(SoupTest):
|
class UserSettings2FATest(SoupTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
@@ -261,7 +267,7 @@ class UserSettings2FATest(SoupTest):
|
|||||||
'name': 'Foo'
|
'name': 'Foo'
|
||||||
}, follow=True)
|
}, follow=True)
|
||||||
|
|
||||||
m = monkeypatch.monkeypatch()
|
m = self.monkeypatch
|
||||||
m.setattr("u2flib_server.u2f.complete_register", lambda *args, **kwargs: (JSONDict({}), None))
|
m.setattr("u2flib_server.u2f.complete_register", lambda *args, **kwargs: (JSONDict({}), None))
|
||||||
|
|
||||||
d = U2FDevice.objects.first()
|
d = U2FDevice.objects.first()
|
||||||
|
|||||||
Reference in New Issue
Block a user