@@ -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 (
@@ -349,63 +359,110 @@ def pytest_addoption(parser):
349
359
assert val == "hello"
350
360
pytest .raises (ValueError , config .getini , "other" )
351
361
352
- def test_addini_pathlist (self , testdir ):
362
+ def make_conftest_for_pathlist (self , testdir ):
353
363
testdir .makeconftest (
354
364
"""
355
365
def pytest_addoption(parser):
356
366
parser.addini("paths", "my new ini value", type="pathlist")
357
367
parser.addini("abc", "abc value")
358
368
"""
359
369
)
370
+
371
+ def test_addini_pathlist_ini_files (self , testdir ):
372
+ self .make_conftest_for_pathlist (testdir )
360
373
p = testdir .makeini (
361
374
"""
362
375
[pytest]
363
376
paths=hello world/sub.py
364
377
"""
365
378
)
379
+ self .check_config_pathlist (testdir , p )
380
+
381
+ def test_addini_pathlist_pyproject_toml (self , testdir ):
382
+ self .make_conftest_for_pathlist (testdir )
383
+ p = testdir .makepyprojecttoml (
384
+ """
385
+ [tool.pytest.ini]
386
+ paths=["hello", "world/sub.py"]
387
+ """
388
+ )
389
+ self .check_config_pathlist (testdir , p )
390
+
391
+ def check_config_pathlist (self , testdir , config_path ):
366
392
config = testdir .parseconfig ()
367
393
values = config .getini ("paths" )
368
394
assert len (values ) == 2
369
- assert values [0 ] == p .dirpath ("hello" )
370
- assert values [1 ] == p .dirpath ("world/sub.py" )
395
+ assert values [0 ] == config_path .dirpath ("hello" )
396
+ assert values [1 ] == config_path .dirpath ("world/sub.py" )
371
397
pytest .raises (ValueError , config .getini , "other" )
372
398
373
- def test_addini_args (self , testdir ):
399
+ def make_conftest_for_args (self , testdir ):
374
400
testdir .makeconftest (
375
401
"""
376
402
def pytest_addoption(parser):
377
403
parser.addini("args", "new args", type="args")
378
404
parser.addini("a2", "", "args", default="1 2 3".split())
379
405
"""
380
406
)
407
+
408
+ def test_addini_args_ini_files (self , testdir ):
409
+ self .make_conftest_for_args (testdir )
381
410
testdir .makeini (
382
411
"""
383
412
[pytest]
384
413
args=123 "123 hello" "this"
385
- """
414
+ """
386
415
)
416
+ self .check_config_args (testdir )
417
+
418
+ def test_addini_args_pyproject_toml (self , testdir ):
419
+ self .make_conftest_for_args (testdir )
420
+ testdir .makepyprojecttoml (
421
+ """
422
+ [tool.pytest.ini]
423
+ args = ["123", "123 hello", "this"]
424
+ """
425
+ )
426
+ self .check_config_args (testdir )
427
+
428
+ def check_config_args (self , testdir ):
387
429
config = testdir .parseconfig ()
388
430
values = config .getini ("args" )
389
- assert len (values ) == 3
390
431
assert values == ["123" , "123 hello" , "this" ]
391
432
values = config .getini ("a2" )
392
433
assert values == list ("123" )
393
434
394
- def test_addini_linelist (self , testdir ):
435
+ def make_conftest_for_linelist (self , testdir ):
395
436
testdir .makeconftest (
396
437
"""
397
438
def pytest_addoption(parser):
398
439
parser.addini("xy", "", type="linelist")
399
440
parser.addini("a2", "", "linelist")
400
441
"""
401
442
)
443
+
444
+ def test_addini_linelist_ini_files (self , testdir ):
445
+ self .make_conftest_for_linelist (testdir )
402
446
testdir .makeini (
403
447
"""
404
448
[pytest]
405
449
xy= 123 345
406
450
second line
407
451
"""
408
452
)
453
+ self .check_config_linelist (testdir )
454
+
455
+ def test_addini_linelist_pprojecttoml (self , testdir ):
456
+ self .make_conftest_for_linelist (testdir )
457
+ testdir .makepyprojecttoml (
458
+ """
459
+ [tool.pytest.ini]
460
+ xy = ["123 345", "second line"]
461
+ """
462
+ )
463
+ self .check_config_linelist (testdir )
464
+
465
+ def check_config_linelist (self , testdir ):
409
466
config = testdir .parseconfig ()
410
467
values = config .getini ("xy" )
411
468
assert len (values ) == 2
0 commit comments