@@ -25,7 +25,7 @@ class TestWhenExplictConfigFileIsPassed:
25
25
def test_returns_path_to_existing_file (self , tmp_path : Path ) -> None :
26
26
"""If an explicit config file is passed, it should be returned."""
27
27
cfg_file = tmp_path / "bump.toml"
28
- cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' )
28
+ cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' , encoding = "utf-8" )
29
29
assert find_config_file (cfg_file ) == cfg_file
30
30
31
31
def test_returns_none_when_missing_file (self , tmp_path : Path ) -> None :
@@ -43,7 +43,7 @@ class TestWhenNoExplicitConfigFileIsPassed:
43
43
def test_returns_path_to_existing_default_file (self , tmp_path : Path , cfg_file_name : str ) -> None :
44
44
"""If no explicit config file is passed, it returns the path to an existing expected file."""
45
45
cfg_file = tmp_path / cfg_file_name
46
- cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' )
46
+ cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' , encoding = "utf-8" )
47
47
with inside_dir (tmp_path ):
48
48
assert find_config_file () == cfg_file
49
49
@@ -57,7 +57,7 @@ def test_returns_path_to_existing_file_in_correct_order(self, tmp_path: Path) ->
57
57
expected_order = list (CONFIG_FILE_SEARCH_ORDER )[:] # make a copy so we can mutate it
58
58
cfg_file_paths = [tmp_path / cfg_file_name for cfg_file_name in expected_order ]
59
59
for cfg_file in cfg_file_paths : # create all the files
60
- cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' )
60
+ cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' , encoding = "utf-8" )
61
61
62
62
with inside_dir (tmp_path ):
63
63
while expected_order :
@@ -101,7 +101,7 @@ def test_returns_empty_dict_with_unknown_suffix(
101
101
caplog .set_level ("INFO" )
102
102
tmp_path = tmp_path_factory .mktemp ("explicit-file-passed-" )
103
103
cfg_file = tmp_path / "basic_cfg.unknown"
104
- cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' )
104
+ cfg_file .write_text ('[tool.bumpversion]\n current_version = "1.0.0"' , encoding = "utf-8" )
105
105
with inside_dir (tmp_path ):
106
106
assert config .read_config_file (cfg_file ) == {}
107
107
assert "Unknown config file suffix" in caplog .text
@@ -132,9 +132,9 @@ def test_read_toml_file(conf_file: str, expected_file: str, fixtures_path: Path)
132
132
def test_multiple_config_files (tmp_path : Path ):
133
133
"""If there are multiple config files, the first one with content wins."""
134
134
setup_cfg = tmp_path / "setup.cfg"
135
- setup_cfg .write_text ("[metadata]\n name: just-a-name\n " )
135
+ setup_cfg .write_text ("[metadata]\n name: just-a-name\n " , encoding = "utf-8" )
136
136
bumpversion_cfg = tmp_path / ".bumpversion.cfg"
137
- bumpversion_cfg .write_text ("\n " )
137
+ bumpversion_cfg .write_text ("\n " , encoding = "utf-8" )
138
138
pyproject_toml = tmp_path / "pyproject.toml"
139
139
pyproject_toml .write_text (
140
140
"[tool.bumpversion]\n "
@@ -143,7 +143,8 @@ def test_multiple_config_files(tmp_path: Path):
143
143
"serialize = [\n "
144
144
' "{major}.{minor}.{patch}-{release}",\n '
145
145
' "{major}.{minor}.{patch}"\n '
146
- "]\n "
146
+ "]\n " ,
147
+ encoding = "utf-8" ,
147
148
)
148
149
with inside_dir (tmp_path ):
149
150
cfg_file = bumpversion .config .files .find_config_file ()
@@ -180,7 +181,7 @@ def test_update_config_file(tmp_path: Path, cfg_file_name: str, fixtures_path: P
180
181
expected_diff = TOML_EXPECTED_DIFF
181
182
cfg_path = tmp_path / cfg_file_name
182
183
orig_path = fixtures_path / f"basic_cfg{ cfg_path .suffix } "
183
- cfg_path .write_text (orig_path .read_text ())
184
+ cfg_path .write_text (orig_path .read_text (), encoding = "utf-8" )
184
185
original_content = orig_path .read_text ().splitlines (keepends = True )
185
186
with inside_dir (tmp_path ):
186
187
cfg = config .get_configuration (cfg_path )
@@ -206,9 +207,9 @@ def test_pep440_config(git_repo: Path, fixtures_path: Path):
206
207
207
208
cfg_path = git_repo / "pyproject.toml"
208
209
orig_path = fixtures_path / "pep440.toml"
209
- cfg_path .write_text (orig_path .read_text ())
210
+ cfg_path .write_text (orig_path .read_text (), encoding = "utf-8" )
210
211
version_path = git_repo / "VERSION"
211
- version_path .write_text ("1.0.0" )
212
+ version_path .write_text ("1.0.0" , encoding = "utf-8" )
212
213
readme_path = git_repo / "README.md"
213
214
runner : CliRunner = CliRunner ()
214
215
@@ -225,7 +226,7 @@ def test_pep440_config(git_repo: Path, fixtures_path: Path):
225
226
assert next_version_str == "1.0.1"
226
227
227
228
subprocess .run (["git" , "checkout" , "-b" , "my-really-LONG-branch_name" ], check = True , capture_output = True )
228
- readme_path .write_text ("This is my branch!" )
229
+ readme_path .write_text ("This is my branch!" , encoding = "utf-8" )
229
230
result : Result = runner .invoke (cli .cli , ["bump" , "dev_label" , "--no-tag" ])
230
231
assert result .exit_code == 0
231
232
cfg = config .get_configuration (cfg_path )
0 commit comments