55import configparser
66import os
77import pathlib
8- import subprocess
98from typing import Any
109
1110import pytest
@@ -279,13 +278,13 @@ def test_append():
279278
280279
281280def test_append_novalue ():
282- err_msg = cmd_raises ('config -a pytest.foo' , subprocess . CalledProcessError )
281+ _ , err_msg = cmd_raises ('config -a pytest.foo' , SystemExit )
283282 assert '-a requires both name and value' in err_msg
284283
285284
286285def test_append_notfound ():
287286 update_testcfg ('pytest' , 'key' , 'val' , configfile = LOCAL )
288- err_msg = cmd_raises ('config -a pytest.foo bar' , subprocess . CalledProcessError )
287+ _ , err_msg = cmd_raises ('config -a pytest.foo bar' , SystemExit )
289288 assert 'option pytest.foo not found in the local configuration file' in err_msg
290289
291290
@@ -425,7 +424,7 @@ def test_delete_cmd_all():
425424 assert cfg (f = ALL )['pytest' ]['key' ] == 'local'
426425 cmd ('config -D pytest.key' )
427426 assert 'pytest' not in cfg (f = ALL )
428- with pytest .raises (subprocess . CalledProcessError ):
427+ with pytest .raises (SystemExit ):
429428 cmd ('config -D pytest.key' )
430429
431430
@@ -439,7 +438,7 @@ def test_delete_cmd_none():
439438 assert cmd ('config pytest.key' ).rstrip () == 'global'
440439 cmd ('config -d pytest.key' )
441440 assert cmd ('config pytest.key' ).rstrip () == 'system'
442- with pytest .raises (subprocess . CalledProcessError ):
441+ with pytest .raises (SystemExit ):
443442 cmd ('config -d pytest.key' )
444443
445444
@@ -449,7 +448,7 @@ def test_delete_cmd_system():
449448 cmd ('config --global pytest.key global' )
450449 cmd ('config --local pytest.key local' )
451450 cmd ('config -d --system pytest.key' )
452- with pytest .raises (subprocess . CalledProcessError ):
451+ with pytest .raises (SystemExit ):
453452 cmd ('config --system pytest.key' )
454453 assert cmd ('config --global pytest.key' ).rstrip () == 'global'
455454 assert cmd ('config --local pytest.key' ).rstrip () == 'local'
@@ -462,7 +461,7 @@ def test_delete_cmd_global():
462461 cmd ('config --local pytest.key local' )
463462 cmd ('config -d --global pytest.key' )
464463 assert cmd ('config --system pytest.key' ).rstrip () == 'system'
465- with pytest .raises (subprocess . CalledProcessError ):
464+ with pytest .raises (SystemExit ):
466465 cmd ('config --global pytest.key' )
467466 assert cmd ('config --local pytest.key' ).rstrip () == 'local'
468467
@@ -475,17 +474,17 @@ def test_delete_cmd_local():
475474 cmd ('config -d --local pytest.key' )
476475 assert cmd ('config --system pytest.key' ).rstrip () == 'system'
477476 assert cmd ('config --global pytest.key' ).rstrip () == 'global'
478- with pytest .raises (subprocess . CalledProcessError ):
477+ with pytest .raises (SystemExit ):
479478 cmd ('config --local pytest.key' )
480479
481480
482481def test_delete_cmd_error ():
483482 # Verify illegal combinations of flags error out.
484- err_msg = cmd_raises ('config -l -d pytest.key' , subprocess . CalledProcessError )
483+ _ , err_msg = cmd_raises ('config -l -d pytest.key' , SystemExit )
485484 assert 'argument -d/--delete: not allowed with argument -l/--list' in err_msg
486- err_msg = cmd_raises ('config -l -D pytest.key' , subprocess . CalledProcessError )
485+ _ , err_msg = cmd_raises ('config -l -D pytest.key' , SystemExit )
487486 assert 'argument -D/--delete-all: not allowed with argument -l/--list' in err_msg
488- err_msg = cmd_raises ('config -d -D pytest.key' , subprocess . CalledProcessError )
487+ _ , err_msg = cmd_raises ('config -d -D pytest.key' , SystemExit )
489488 assert 'argument -D/--delete-all: not allowed with argument -d/--delete' in err_msg
490489
491490
@@ -519,27 +518,27 @@ def test_config_precedence():
519518
520519
521520def test_config_missing_key ():
522- err_msg = cmd_raises ('config pytest' , subprocess . CalledProcessError )
521+ _ , err_msg = cmd_raises ('config pytest' , SystemExit )
523522 assert 'invalid configuration option "pytest"; expected "section.key" format' in err_msg
524523
525524
526525def test_unset_config ():
527526 # Getting unset configuration options should raise an error.
528527 # With verbose output, the exact missing option should be printed.
529- err_msg = cmd_raises ('-v config pytest.missing' , subprocess . CalledProcessError )
528+ _ , err_msg = cmd_raises ('-v config pytest.missing' , SystemExit )
530529 assert 'pytest.missing is unset' in err_msg
531530
532531
533532def test_no_args ():
534- err_msg = cmd_raises ('config' , subprocess . CalledProcessError )
533+ _ , err_msg = cmd_raises ('config' , SystemExit )
535534 assert 'missing argument name' in err_msg
536535
537536
538537def test_list ():
539538 def sorted_list (other_args = '' ):
540539 return list (sorted (cmd ('config -l ' + other_args ).splitlines ()))
541540
542- err_msg = cmd_raises ('config -l pytest.foo' , subprocess . CalledProcessError )
541+ _ , err_msg = cmd_raises ('config -l pytest.foo' , SystemExit )
543542 assert '-l cannot be combined with name argument' in err_msg
544543
545544 assert cmd ('config -l' ).strip () == ''
0 commit comments