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