Skip to content

Commit 390f06a

Browse files
committed
Add more explict encodings in test_pyprojecttoml
1 parent e1cd88c commit 390f06a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

setuptools/tests/config/test_pyprojecttoml.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,13 @@ def test_dynamic(self, tmp_path):
216216
# Let's create a project example that has dynamic classifiers
217217
# coming from a txt file.
218218
create_example(tmp_path, "src")
219-
classifiers = """\
220-
Framework :: Flask
221-
Programming Language :: Haskell
222-
"""
223-
(tmp_path / "classifiers.txt").write_text(cleandoc(classifiers))
219+
classifiers = cleandoc(
220+
"""
221+
Framework :: Flask
222+
Programming Language :: Haskell
223+
"""
224+
)
225+
(tmp_path / "classifiers.txt").write_text(classifiers, encoding="utf-8")
224226

225227
pyproject = tmp_path / "pyproject.toml"
226228
config = read_configuration(pyproject, expand=False)
@@ -248,7 +250,7 @@ def test_dynamic_without_config(self, tmp_path):
248250
"""
249251

250252
pyproject = tmp_path / "pyproject.toml"
251-
pyproject.write_text(cleandoc(config))
253+
pyproject.write_text(cleandoc(config), encoding="utf-8")
252254
with pytest.raises(OptionError, match="No configuration .* .classifiers."):
253255
read_configuration(pyproject)
254256

@@ -260,7 +262,7 @@ def test_dynamic_readme_from_setup_script_args(self, tmp_path):
260262
dynamic = ["readme"]
261263
"""
262264
pyproject = tmp_path / "pyproject.toml"
263-
pyproject.write_text(cleandoc(config))
265+
pyproject.write_text(cleandoc(config), encoding="utf-8")
264266
dist = Distribution(attrs={"long_description": "42"})
265267
# No error should occur because of missing `readme`
266268
dist = apply_configuration(dist, pyproject)
@@ -278,7 +280,7 @@ def test_dynamic_without_file(self, tmp_path):
278280
"""
279281

280282
pyproject = tmp_path / "pyproject.toml"
281-
pyproject.write_text(cleandoc(config))
283+
pyproject.write_text(cleandoc(config), encoding="utf-8")
282284
with pytest.warns(UserWarning, match="File .*classifiers.txt. cannot be found"):
283285
expanded = read_configuration(pyproject)
284286
assert "classifiers" not in expanded["project"]
@@ -299,7 +301,7 @@ def test_dynamic_without_file(self, tmp_path):
299301
)
300302
def test_ignore_unrelated_config(tmp_path, example):
301303
pyproject = tmp_path / "pyproject.toml"
302-
pyproject.write_text(cleandoc(example))
304+
pyproject.write_text(cleandoc(example), encoding="utf-8")
303305

304306
# Make sure no error is raised due to 3rd party configs in pyproject.toml
305307
assert read_configuration(pyproject) is not None
@@ -321,7 +323,7 @@ def test_ignore_unrelated_config(tmp_path, example):
321323
)
322324
def test_invalid_example(tmp_path, example, error_msg):
323325
pyproject = tmp_path / "pyproject.toml"
324-
pyproject.write_text(cleandoc(example))
326+
pyproject.write_text(cleandoc(example), encoding="utf-8")
325327

326328
pattern = re.compile(f"invalid pyproject.toml.*{error_msg}.*", re.M | re.S)
327329
with pytest.raises(ValueError, match=pattern):
@@ -331,7 +333,7 @@ def test_invalid_example(tmp_path, example, error_msg):
331333
@pytest.mark.parametrize("config", ("", "[tool.something]\nvalue = 42"))
332334
def test_empty(tmp_path, config):
333335
pyproject = tmp_path / "pyproject.toml"
334-
pyproject.write_text(config)
336+
pyproject.write_text(config, encoding="utf-8")
335337

336338
# Make sure no error is raised
337339
assert read_configuration(pyproject) == {}
@@ -343,7 +345,7 @@ def test_include_package_data_by_default(tmp_path, config):
343345
default.
344346
"""
345347
pyproject = tmp_path / "pyproject.toml"
346-
pyproject.write_text(config)
348+
pyproject.write_text(config, encoding="utf-8")
347349

348350
config = read_configuration(pyproject)
349351
assert config["tool"]["setuptools"]["include-package-data"] is True

0 commit comments

Comments
 (0)