55import configparser
66import os
77import pathlib
8- import subprocess
98import textwrap
109from typing import Any
1110
@@ -351,13 +350,13 @@ def test_append():
351350
352351
353352def test_append_novalue ():
354- err_msg = cmd_raises ('config -a pytest.foo' , subprocess . CalledProcessError )
353+ _ , err_msg = cmd_raises ('config -a pytest.foo' , SystemExit )
355354 assert '-a requires both name and value' in err_msg
356355
357356
358357def test_append_notfound ():
359358 update_testcfg ('pytest' , 'key' , 'val' , configfile = LOCAL )
360- err_msg = cmd_raises ('config -a pytest.foo bar' , subprocess . CalledProcessError )
359+ _ , err_msg = cmd_raises ('config -a pytest.foo bar' , SystemExit )
361360 assert 'option pytest.foo not found in the local configuration file' in err_msg
362361
363362
@@ -497,7 +496,7 @@ def test_delete_cmd_all():
497496 assert cfg (f = ALL )['pytest' ]['key' ] == 'local'
498497 cmd ('config -D pytest.key' )
499498 assert 'pytest' not in cfg (f = ALL )
500- with pytest .raises (subprocess . CalledProcessError ):
499+ with pytest .raises (SystemExit ):
501500 cmd ('config -D pytest.key' )
502501
503502
@@ -511,7 +510,7 @@ def test_delete_cmd_none():
511510 assert cmd ('config pytest.key' ).rstrip () == 'global'
512511 cmd ('config -d pytest.key' )
513512 assert cmd ('config pytest.key' ).rstrip () == 'system'
514- with pytest .raises (subprocess . CalledProcessError ):
513+ with pytest .raises (SystemExit ):
515514 cmd ('config -d pytest.key' )
516515
517516
@@ -521,7 +520,7 @@ def test_delete_cmd_system():
521520 cmd ('config --global pytest.key global' )
522521 cmd ('config --local pytest.key local' )
523522 cmd ('config -d --system pytest.key' )
524- with pytest .raises (subprocess . CalledProcessError ):
523+ with pytest .raises (SystemExit ):
525524 cmd ('config --system pytest.key' )
526525 assert cmd ('config --global pytest.key' ).rstrip () == 'global'
527526 assert cmd ('config --local pytest.key' ).rstrip () == 'local'
@@ -534,7 +533,7 @@ def test_delete_cmd_global():
534533 cmd ('config --local pytest.key local' )
535534 cmd ('config -d --global pytest.key' )
536535 assert cmd ('config --system pytest.key' ).rstrip () == 'system'
537- with pytest .raises (subprocess . CalledProcessError ):
536+ with pytest .raises (SystemExit ):
538537 cmd ('config --global pytest.key' )
539538 assert cmd ('config --local pytest.key' ).rstrip () == 'local'
540539
@@ -547,17 +546,17 @@ def test_delete_cmd_local():
547546 cmd ('config -d --local pytest.key' )
548547 assert cmd ('config --system pytest.key' ).rstrip () == 'system'
549548 assert cmd ('config --global pytest.key' ).rstrip () == 'global'
550- with pytest .raises (subprocess . CalledProcessError ):
549+ with pytest .raises (SystemExit ):
551550 cmd ('config --local pytest.key' )
552551
553552
554553def test_delete_cmd_error ():
555554 # Verify illegal combinations of flags error out.
556- err_msg = cmd_raises ('config -l -d pytest.key' , subprocess . CalledProcessError )
555+ _ , err_msg = cmd_raises ('config -l -d pytest.key' , SystemExit )
557556 assert 'argument -d/--delete: not allowed with argument -l/--list' in err_msg
558- err_msg = cmd_raises ('config -l -D pytest.key' , subprocess . CalledProcessError )
557+ _ , err_msg = cmd_raises ('config -l -D pytest.key' , SystemExit )
559558 assert 'argument -D/--delete-all: not allowed with argument -l/--list' in err_msg
560- err_msg = cmd_raises ('config -d -D pytest.key' , subprocess . CalledProcessError )
559+ _ , err_msg = cmd_raises ('config -d -D pytest.key' , SystemExit )
561560 assert 'argument -D/--delete-all: not allowed with argument -d/--delete' in err_msg
562561
563562
@@ -591,27 +590,27 @@ def test_config_precedence():
591590
592591
593592def test_config_missing_key ():
594- err_msg = cmd_raises ('config pytest' , subprocess . CalledProcessError )
593+ _ , err_msg = cmd_raises ('config pytest' , SystemExit )
595594 assert 'invalid configuration option "pytest"; expected "section.key" format' in err_msg
596595
597596
598597def test_unset_config ():
599598 # Getting unset configuration options should raise an error.
600599 # With verbose output, the exact missing option should be printed.
601- err_msg = cmd_raises ('-v config pytest.missing' , subprocess . CalledProcessError )
600+ _ , err_msg = cmd_raises ('-v config pytest.missing' , SystemExit )
602601 assert 'pytest.missing is unset' in err_msg
603602
604603
605604def test_no_args ():
606- err_msg = cmd_raises ('config' , subprocess . CalledProcessError )
605+ _ , err_msg = cmd_raises ('config' , SystemExit )
607606 assert 'missing argument name' in err_msg
608607
609608
610609def test_list ():
611610 def sorted_list (other_args = '' ):
612611 return list (sorted (cmd ('config -l ' + other_args ).splitlines ()))
613612
614- err_msg = cmd_raises ('config -l pytest.foo' , subprocess . CalledProcessError )
613+ _ , err_msg = cmd_raises ('config -l pytest.foo' , SystemExit )
615614 assert '-l cannot be combined with name argument' in err_msg
616615
617616 assert cmd ('config -l' ).strip () == ''
0 commit comments