@@ -98,11 +98,17 @@ def create_example(path, pkg_root):
98
98
(path / file ).parent .mkdir (exist_ok = True , parents = True )
99
99
(path / file ).touch ()
100
100
101
- pyproject .write_text (EXAMPLE )
102
- (path / "README.md" ).write_text ("hello world" )
103
- (path / f"{ pkg_root } /pkg/mod.py" ).write_text ("class CustomSdist: pass" )
104
- (path / f"{ pkg_root } /pkg/__version__.py" ).write_text ("VERSION = (3, 10)" )
105
- (path / f"{ pkg_root } /pkg/__main__.py" ).write_text ("def exec(): print('hello')" )
101
+ pyproject .write_text (EXAMPLE , encoding = encoding_for_open )
102
+ (path / "README.md" ).write_text ("hello world" , encoding = encoding_for_open )
103
+ (path / f"{ pkg_root } /pkg/mod.py" ).write_text (
104
+ "class CustomSdist: pass" , encoding = encoding_for_open
105
+ )
106
+ (path / f"{ pkg_root } /pkg/__version__.py" ).write_text (
107
+ "VERSION = (3, 10)" , encoding = encoding_for_open
108
+ )
109
+ (path / f"{ pkg_root } /pkg/__main__.py" ).write_text (
110
+ "def exec(): print('hello')" , encoding = encoding_for_open
111
+ )
106
112
107
113
108
114
def verify_example (config , path , pkg_root ):
@@ -218,7 +224,9 @@ def test_dynamic(self, tmp_path):
218
224
Framework :: Flask
219
225
Programming Language :: Haskell
220
226
"""
221
- (tmp_path / "classifiers.txt" ).write_text (cleandoc (classifiers ))
227
+ (tmp_path / "classifiers.txt" ).write_text (
228
+ cleandoc (classifiers ), encoding = encoding_for_open
229
+ )
222
230
223
231
pyproject = tmp_path / "pyproject.toml"
224
232
config = read_configuration (pyproject , expand = False )
@@ -246,7 +254,7 @@ def test_dynamic_without_config(self, tmp_path):
246
254
"""
247
255
248
256
pyproject = tmp_path / "pyproject.toml"
249
- pyproject .write_text (cleandoc (config ))
257
+ pyproject .write_text (cleandoc (config ), encoding = encoding_for_open )
250
258
with pytest .raises (OptionError , match = "No configuration .* .classifiers." ):
251
259
read_configuration (pyproject )
252
260
@@ -258,7 +266,7 @@ def test_dynamic_readme_from_setup_script_args(self, tmp_path):
258
266
dynamic = ["readme"]
259
267
"""
260
268
pyproject = tmp_path / "pyproject.toml"
261
- pyproject .write_text (cleandoc (config ))
269
+ pyproject .write_text (cleandoc (config ), encoding = encoding_for_open )
262
270
dist = Distribution (attrs = {"long_description" : "42" })
263
271
# No error should occur because of missing `readme`
264
272
dist = apply_configuration (dist , pyproject )
@@ -276,7 +284,7 @@ def test_dynamic_without_file(self, tmp_path):
276
284
"""
277
285
278
286
pyproject = tmp_path / "pyproject.toml"
279
- pyproject .write_text (cleandoc (config ))
287
+ pyproject .write_text (cleandoc (config ), encoding = encoding_for_open )
280
288
with pytest .warns (UserWarning , match = "File .*classifiers.txt. cannot be found" ):
281
289
expanded = read_configuration (pyproject )
282
290
assert "classifiers" not in expanded ["project" ]
@@ -297,7 +305,7 @@ def test_dynamic_without_file(self, tmp_path):
297
305
)
298
306
def test_ignore_unrelated_config (tmp_path , example ):
299
307
pyproject = tmp_path / "pyproject.toml"
300
- pyproject .write_text (cleandoc (example ))
308
+ pyproject .write_text (cleandoc (example ), encoding = encoding_for_open )
301
309
302
310
# Make sure no error is raised due to 3rd party configs in pyproject.toml
303
311
assert read_configuration (pyproject ) is not None
@@ -319,7 +327,7 @@ def test_ignore_unrelated_config(tmp_path, example):
319
327
)
320
328
def test_invalid_example (tmp_path , example , error_msg ):
321
329
pyproject = tmp_path / "pyproject.toml"
322
- pyproject .write_text (cleandoc (example ))
330
+ pyproject .write_text (cleandoc (example ), encoding = encoding_for_open )
323
331
324
332
pattern = re .compile (f"invalid pyproject.toml.*{ error_msg } .*" , re .M | re .S )
325
333
with pytest .raises (ValueError , match = pattern ):
@@ -329,7 +337,7 @@ def test_invalid_example(tmp_path, example, error_msg):
329
337
@pytest .mark .parametrize ("config" , ("" , "[tool.something]\n value = 42" ))
330
338
def test_empty (tmp_path , config ):
331
339
pyproject = tmp_path / "pyproject.toml"
332
- pyproject .write_text (config )
340
+ pyproject .write_text (config , encoding = encoding_for_open )
333
341
334
342
# Make sure no error is raised
335
343
assert read_configuration (pyproject ) == {}
@@ -341,7 +349,7 @@ def test_include_package_data_by_default(tmp_path, config):
341
349
default.
342
350
"""
343
351
pyproject = tmp_path / "pyproject.toml"
344
- pyproject .write_text (config )
352
+ pyproject .write_text (config , encoding = encoding_for_open )
345
353
346
354
config = read_configuration (pyproject )
347
355
assert config ["tool" ]["setuptools" ]["include-package-data" ] is True
@@ -354,9 +362,14 @@ def test_include_package_data_in_setuppy(tmp_path):
354
362
See https://github.com/pypa/setuptools/issues/3197#issuecomment-1079023889
355
363
"""
356
364
pyproject = tmp_path / "pyproject.toml"
357
- pyproject .write_text ("[project]\n name = 'myproj'\n version='42'\n " )
365
+ pyproject .write_text (
366
+ "[project]\n name = 'myproj'\n version='42'\n " , encoding = encoding_for_open
367
+ )
358
368
setuppy = tmp_path / "setup.py"
359
- setuppy .write_text ("__import__('setuptools').setup(include_package_data=False)" )
369
+ setuppy .write_text (
370
+ "__import__('setuptools').setup(include_package_data=False)" ,
371
+ encoding = encoding_for_open ,
372
+ )
360
373
361
374
with _Path (tmp_path ):
362
375
dist = distutils .core .run_setup ("setup.py" , {}, stop_after = "config" )
0 commit comments