-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
38 lines (29 loc) · 845 Bytes
/
conftest.py
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
29
30
31
32
33
34
35
36
37
38
import pytest
from unittest.mock import patch
MARKER = """\
unit: Mark unit test
high: High Priority
medium: Medium Priority
low: Low Priority
"""
def pytest_configure(config):
for line in MARKER.split("\n"):
config.addinivalue_line("markers", line)
@pytest.fixture(autouse=True)
def go_to_tmpdir(request):
"""
Change to temporary directory before each test
"""
tmpdir = request.getfixturevalue("tmpdir")
with tmpdir.as_cwd():
yield
@pytest.fixture(autouse=True, scope="function")
def setup_testing_database(request):
"""
For each test, create a temporary database
force database.py to use that filepath
"""
tmpdir = request.getfixturevalue("tmpdir")
test_db = str(tmpdir.join("database.test.json"))
with patch("dundie.database.DATABASE_PATH", test_db):
yield