1
- import logging
2
1
import re
3
2
from configparser import ConfigParser
4
3
from inspect import cleandoc
@@ -307,7 +306,7 @@ def test_ignore_unrelated_config(tmp_path, example):
307
306
308
307
309
308
@pytest .mark .parametrize (
310
- "example, error_msg, value_shown_in_debug " ,
309
+ "example, error_msg" ,
311
310
[
312
311
(
313
312
"""
@@ -316,30 +315,18 @@ def test_ignore_unrelated_config(tmp_path, example):
316
315
version = "1.2"
317
316
requires = ['pywin32; platform_system=="Windows"' ]
318
317
""" ,
319
- "configuration error: `project` must not contain {'requires'} properties" ,
320
- '"requires": ["pywin32; platform_system==\\ "Windows\\ ""]' ,
318
+ "configuration error: .project. must not contain ..requires.. properties" ,
321
319
),
322
320
],
323
321
)
324
- def test_invalid_example (tmp_path , caplog , example , error_msg , value_shown_in_debug ):
325
- caplog .set_level (logging .DEBUG )
322
+ def test_invalid_example (tmp_path , example , error_msg ):
326
323
pyproject = tmp_path / "pyproject.toml"
327
324
pyproject .write_text (cleandoc (example ))
328
325
329
- caplog . clear ( )
330
- with pytest .raises (ValueError , match = "invalid pyproject.toml" ):
326
+ pattern = re . compile ( f"invalid pyproject.toml.* { error_msg } .*" , re . M | re . S )
327
+ with pytest .raises (ValueError , match = pattern ):
331
328
read_configuration (pyproject )
332
329
333
- # Make sure the logs give guidance to the user
334
- error_log = caplog .record_tuples [0 ]
335
- assert error_log [1 ] == logging .ERROR
336
- assert error_msg in error_log [2 ]
337
-
338
- debug_log = caplog .record_tuples [1 ]
339
- assert debug_log [1 ] == logging .DEBUG
340
- debug_msg = "" .join (line .strip () for line in debug_log [2 ].splitlines ())
341
- assert value_shown_in_debug in debug_msg
342
-
343
330
344
331
@pytest .mark .parametrize ("config" , ("" , "[tool.something]\n value = 42" ))
345
332
def test_empty (tmp_path , config ):
0 commit comments