1
- from pathlib import Path
2
1
from shutil import copyfile
3
2
4
3
import pytest
5
4
6
5
from commitizen import bump
7
6
from commitizen .exceptions import CurrentVersionNotFoundError
7
+ from tests .utils import copy_sample_file_to_tmpdir
8
8
9
9
MULTIPLE_VERSIONS_INCREASE_STRING = 'version = "1.2.9"\n ' * 30
10
10
MULTIPLE_VERSIONS_REDUCE_STRING = 'version = "1.2.10"\n ' * 30
11
11
12
12
TESTING_FILE_PREFIX = "tests/data"
13
13
14
14
15
- def _copy_sample_file_to_tmpdir (
16
- tmp_path : Path , source_filename : str , dest_filename : str
17
- ) -> Path :
18
- tmp_file = tmp_path / dest_filename
19
- copyfile (f"{ TESTING_FILE_PREFIX } /{ source_filename } " , tmp_file )
20
- return tmp_file
21
-
22
-
23
15
@pytest .fixture (scope = "function" )
24
16
def commitizen_config_file (tmpdir ):
25
- return _copy_sample_file_to_tmpdir (
26
- tmpdir , "sample_pyproject.toml" , "pyproject.toml"
27
- )
17
+ return copy_sample_file_to_tmpdir (tmpdir , "sample_pyproject.toml" , "pyproject.toml" )
28
18
29
19
30
20
@pytest .fixture (scope = "function" )
31
21
def python_version_file (tmpdir , request ):
32
- return _copy_sample_file_to_tmpdir (tmpdir , "sample_version.py" , "__version__.py" )
22
+ return copy_sample_file_to_tmpdir (tmpdir , "sample_version.py" , "__version__.py" )
33
23
34
24
35
25
@pytest .fixture (scope = "function" )
36
26
def inconsistent_python_version_file (tmpdir ):
37
- return _copy_sample_file_to_tmpdir (
27
+ return copy_sample_file_to_tmpdir (
38
28
tmpdir , "inconsistent_version.py" , "__version__.py"
39
29
)
40
30
41
31
42
32
@pytest .fixture (scope = "function" )
43
33
def random_location_version_file (tmpdir ):
44
- return _copy_sample_file_to_tmpdir (tmpdir , "sample_cargo.lock" , "Cargo.lock" )
34
+ return copy_sample_file_to_tmpdir (tmpdir , "sample_cargo.lock" , "Cargo.lock" )
45
35
46
36
47
37
@pytest .fixture (scope = "function" )
48
38
def version_repeated_file (tmpdir ):
49
- return _copy_sample_file_to_tmpdir (
39
+ return copy_sample_file_to_tmpdir (
50
40
tmpdir , "repeated_version_number.json" , "package.json"
51
41
)
52
42
53
43
54
44
@pytest .fixture (scope = "function" )
55
45
def docker_compose_file (tmpdir ):
56
- return _copy_sample_file_to_tmpdir (
46
+ return copy_sample_file_to_tmpdir (
57
47
tmpdir , "sample_docker_compose.yaml" , "docker-compose.yaml"
58
48
)
59
49
@@ -67,7 +57,7 @@ def docker_compose_file(tmpdir):
67
57
ids = ("with_eol" , "without_eol" ),
68
58
)
69
59
def multiple_versions_to_update_poetry_lock (tmpdir , request ):
70
- return _copy_sample_file_to_tmpdir (tmpdir , request .param , "pyproject.toml" )
60
+ return copy_sample_file_to_tmpdir (tmpdir , request .param , "pyproject.toml" )
71
61
72
62
73
63
@pytest .fixture (scope = "function" )
0 commit comments