-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathconftest.py
More file actions
28 lines (20 loc) · 838 Bytes
/
conftest.py
File metadata and controls
28 lines (20 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pytest
from waldur_core.permissions.models import RoleManager
def pytest_configure(config):
config.addinivalue_line(
"markers",
"slow: marks tests as slow / load tests (deselect with '-m \"not slow\"')",
)
@pytest.fixture(autouse=True)
def _clear_role_cache():
RoleManager.clear_cache()
yield
RoleManager.clear_cache()
@pytest.fixture(autouse=True)
def _immediate_on_commit(monkeypatch):
# transaction.on_commit callbacks are not executed in TestCase because
# each test is wrapped in a transaction that gets rolled back instead of
# committed. Patch on_commit to execute callbacks immediately so that
# tests behave the same way as production code.
from django.db import transaction
monkeypatch.setattr(transaction, "on_commit", lambda func, using=None: func())