-
Notifications
You must be signed in to change notification settings - Fork 3
/
conftest.py
94 lines (63 loc) · 2.44 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from __future__ import annotations
import os
from pathlib import Path
from typing import Any, Generator
import pytest
from mscxyz import Score
from mscxyz.fields import FieldsManager
from tests import helper
@pytest.fixture(autouse=True)
def score2x() -> Score:
"""Instantiate a Score object from the file simple.mscx (version 2)."""
return helper.get_score("simple.mscx", version=2)
@pytest.fixture(autouse=True)
def score3x() -> Score:
"""Instantiate a Score object from the file simple.mscx (version 3)."""
return helper.get_score("simple.mscx", version=3)
@pytest.fixture(autouse=True)
def score4x() -> Score:
"""Instantiate a Score object from the file simple.mscx (version 4)."""
return helper.get_score("simple.mscx", version=4)
@pytest.fixture(autouse=True)
def score2z() -> Score:
"""Instantiate a Score object from the file simple.mscz (version 2)."""
return helper.get_score("simple.mscz", version=2)
@pytest.fixture(autouse=True)
def score3z() -> Score:
"""Instantiate a Score object from the file simple.mscz (version 3)."""
return helper.get_score("simple.mscz", version=3)
@pytest.fixture(autouse=True)
def score4z() -> Score:
"""Instantiate a Score object from the file simple.mscz (version 4)."""
return helper.get_score("score.mscz", version=4)
@pytest.fixture(autouse=True, scope="function")
def score() -> Score:
"""Instantiate a Score object from the file simple.mscz (version 4)."""
return helper.get_score("score.mscz", version=4)
@pytest.fixture(autouse=True)
def fields() -> FieldsManager:
"""Instantiate a Score object from the file simple.mscz (version 4)."""
return helper.get_fields("score.mscz", version=4)
@pytest.fixture(autouse=True)
def score_path() -> Path:
return helper.get_path("score.mscz", version=4)
@pytest.fixture(autouse=True)
def score_file() -> str:
return helper.get_file("score.mscz", version=4)
@pytest.fixture(autouse=True)
def nested_dir() -> Path:
return Path(helper.get_dir("nested-folders", version=4))
def _chdir(dstdir: Path) -> Generator[Path, Any, None]:
"""https://github.com/ar90n/pytest-chdir"""
lwd = os.getcwd()
os.chdir(dstdir)
try:
yield dstdir
finally:
os.chdir(lwd)
@pytest.fixture
def cwd_tmpdir(tmpdir: Path) -> Generator[Path, Any, None]:
yield from _chdir(tmpdir)
@pytest.fixture
def cwd_test_path() -> Generator[Path, Any, None]:
yield from _chdir(Path(__file__).parent)