1- from pathlib import Path
21from shutil import copyfile
32
43import pytest
54
65from commitizen import bump
76from commitizen .exceptions import CurrentVersionNotFoundError
7+ from tests .utils import copy_sample_file_to_tmpdir
88
99MULTIPLE_VERSIONS_INCREASE_STRING = 'version = "1.2.9"\n ' * 30
1010MULTIPLE_VERSIONS_REDUCE_STRING = 'version = "1.2.10"\n ' * 30
1111
1212TESTING_FILE_PREFIX = "tests/data"
1313
1414
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-
2315@pytest .fixture (scope = "function" )
2416def 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" )
2818
2919
3020@pytest .fixture (scope = "function" )
3121def 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" )
3323
3424
3525@pytest .fixture (scope = "function" )
3626def inconsistent_python_version_file (tmpdir ):
37- return _copy_sample_file_to_tmpdir (
27+ return copy_sample_file_to_tmpdir (
3828 tmpdir , "inconsistent_version.py" , "__version__.py"
3929 )
4030
4131
4232@pytest .fixture (scope = "function" )
4333def 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" )
4535
4636
4737@pytest .fixture (scope = "function" )
4838def version_repeated_file (tmpdir ):
49- return _copy_sample_file_to_tmpdir (
39+ return copy_sample_file_to_tmpdir (
5040 tmpdir , "repeated_version_number.json" , "package.json"
5141 )
5242
5343
5444@pytest .fixture (scope = "function" )
5545def docker_compose_file (tmpdir ):
56- return _copy_sample_file_to_tmpdir (
46+ return copy_sample_file_to_tmpdir (
5747 tmpdir , "sample_docker_compose.yaml" , "docker-compose.yaml"
5848 )
5949
@@ -67,7 +57,7 @@ def docker_compose_file(tmpdir):
6757 ids = ("with_eol" , "without_eol" ),
6858)
6959def 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" )
7161
7262
7363@pytest .fixture (scope = "function" )
0 commit comments