@@ -109,6 +109,16 @@ def test_ini_names(self, testdir, name, section):
109
109
config = testdir .parseconfig ()
110
110
assert config .getini ("minversion" ) == "1.0"
111
111
112
+ def test_pyproject_toml (self , testdir ):
113
+ testdir .makepyprojecttoml (
114
+ """
115
+ [tool.pytest.ini]
116
+ minversion = "1.0"
117
+ """
118
+ )
119
+ config = testdir .parseconfig ()
120
+ assert config .getini ("minversion" ) == "1.0"
121
+
112
122
def test_toxini_before_lower_pytestini (self , testdir ):
113
123
sub = testdir .tmpdir .mkdir ("sub" )
114
124
sub .join ("tox.ini" ).write (
@@ -287,63 +297,110 @@ def pytest_addoption(parser):
287
297
assert val == "hello"
288
298
pytest .raises (ValueError , config .getini , "other" )
289
299
290
- def test_addini_pathlist (self , testdir ):
300
+ def make_conftest_for_pathlist (self , testdir ):
291
301
testdir .makeconftest (
292
302
"""
293
303
def pytest_addoption(parser):
294
304
parser.addini("paths", "my new ini value", type="pathlist")
295
305
parser.addini("abc", "abc value")
296
306
"""
297
307
)
308
+
309
+ def test_addini_pathlist_ini_files (self , testdir ):
310
+ self .make_conftest_for_pathlist (testdir )
298
311
p = testdir .makeini (
299
312
"""
300
313
[pytest]
301
314
paths=hello world/sub.py
302
315
"""
303
316
)
317
+ self .check_config_pathlist (testdir , p )
318
+
319
+ def test_addini_pathlist_pyproject_toml (self , testdir ):
320
+ self .make_conftest_for_pathlist (testdir )
321
+ p = testdir .makepyprojecttoml (
322
+ """
323
+ [tool.pytest.ini]
324
+ paths=["hello", "world/sub.py"]
325
+ """
326
+ )
327
+ self .check_config_pathlist (testdir , p )
328
+
329
+ def check_config_pathlist (self , testdir , config_path ):
304
330
config = testdir .parseconfig ()
305
331
values = config .getini ("paths" )
306
332
assert len (values ) == 2
307
- assert values [0 ] == p .dirpath ("hello" )
308
- assert values [1 ] == p .dirpath ("world/sub.py" )
333
+ assert values [0 ] == config_path .dirpath ("hello" )
334
+ assert values [1 ] == config_path .dirpath ("world/sub.py" )
309
335
pytest .raises (ValueError , config .getini , "other" )
310
336
311
- def test_addini_args (self , testdir ):
337
+ def make_conftest_for_args (self , testdir ):
312
338
testdir .makeconftest (
313
339
"""
314
340
def pytest_addoption(parser):
315
341
parser.addini("args", "new args", type="args")
316
342
parser.addini("a2", "", "args", default="1 2 3".split())
317
343
"""
318
344
)
345
+
346
+ def test_addini_args_ini_files (self , testdir ):
347
+ self .make_conftest_for_args (testdir )
319
348
testdir .makeini (
320
349
"""
321
350
[pytest]
322
351
args=123 "123 hello" "this"
323
- """
352
+ """
324
353
)
354
+ self .check_config_args (testdir )
355
+
356
+ def test_addini_args_pyproject_toml (self , testdir ):
357
+ self .make_conftest_for_args (testdir )
358
+ testdir .makepyprojecttoml (
359
+ """
360
+ [tool.pytest.ini]
361
+ args = ["123", "123 hello", "this"]
362
+ """
363
+ )
364
+ self .check_config_args (testdir )
365
+
366
+ def check_config_args (self , testdir ):
325
367
config = testdir .parseconfig ()
326
368
values = config .getini ("args" )
327
- assert len (values ) == 3
328
369
assert values == ["123" , "123 hello" , "this" ]
329
370
values = config .getini ("a2" )
330
371
assert values == list ("123" )
331
372
332
- def test_addini_linelist (self , testdir ):
373
+ def make_conftest_for_linelist (self , testdir ):
333
374
testdir .makeconftest (
334
375
"""
335
376
def pytest_addoption(parser):
336
377
parser.addini("xy", "", type="linelist")
337
378
parser.addini("a2", "", "linelist")
338
379
"""
339
380
)
381
+
382
+ def test_addini_linelist_ini_files (self , testdir ):
383
+ self .make_conftest_for_linelist (testdir )
340
384
testdir .makeini (
341
385
"""
342
386
[pytest]
343
387
xy= 123 345
344
388
second line
345
389
"""
346
390
)
391
+ self .check_config_linelist (testdir )
392
+
393
+ def test_addini_linelist_pprojecttoml (self , testdir ):
394
+ self .make_conftest_for_linelist (testdir )
395
+ testdir .makepyprojecttoml (
396
+ """
397
+ [tool.pytest.ini]
398
+ xy = ["123 345", "second line"]
399
+ """
400
+ )
401
+ self .check_config_linelist (testdir )
402
+
403
+ def check_config_linelist (self , testdir ):
347
404
config = testdir .parseconfig ()
348
405
values = config .getini ("xy" )
349
406
assert len (values ) == 2
0 commit comments