33from conftest import assert_bash_exec , bash_env_saved
44
55
6- @pytest .mark .bashcomp (cmd = None , cwd = "shared" , ignore_env = r"^\+COMPREPLY=" )
6+ @pytest .mark .bashcomp (
7+ cmd = None , cwd = "shared" , ignore_env = r"^\+declare -f __tester$"
8+ )
79class TestUnitRealCommand :
10+ @pytest .fixture
11+ def functions (self , bash ):
12+ assert_bash_exec (
13+ bash ,
14+ (
15+ "__tester() { "
16+ "local ret rc; "
17+ '_comp_realcommand "$1"; '
18+ "rc=$?; "
19+ 'printf %s "$ret"; '
20+ "return $rc; "
21+ "}"
22+ ),
23+ )
24+
825 def test_non_pollution (self , bash ):
926 """Test environment non-pollution, detected at teardown."""
1027 assert_bash_exec (
1128 bash ,
12- "foo() { local cur =; _realcommand bar; }; foo; unset -f foo" ,
29+ "foo() { local ret =; _comp_realcommand bar; }; foo; unset -f foo" ,
1330 want_output = None ,
1431 )
1532
16- def test_basename (self , bash ):
33+ def test_basename (self , bash , functions ):
1734 with bash_env_saved (bash ) as bash_env :
1835 bash_env .write_variable ("PATH" , "$PWD/bin:$PATH" , quote = False )
1936 output = assert_bash_exec (
2037 bash ,
21- "_realcommand arp" ,
38+ "__tester arp" ,
2239 want_output = True ,
40+ want_newline = False ,
2341 )
2442 assert output .strip ().endswith ("/shared/bin/arp" )
2543
26- def test_basename_nonexistent (self , bash ):
44+ def test_basename_nonexistent (self , bash , functions ):
2745 filename = "non-existent-file-for-bash-completion-tests"
2846 skipif = "! type -P %s" % filename
2947 try :
@@ -32,39 +50,41 @@ def test_basename_nonexistent(self, bash):
3250 pytest .skipif (skipif )
3351 output = assert_bash_exec (
3452 bash ,
35- "! _realcommand %s" % filename ,
53+ "! __tester %s" % filename ,
3654 want_output = False ,
3755 )
3856 assert output .strip () == ""
3957
40- def test_relative (self , bash ):
58+ def test_relative (self , bash , functions ):
4159 output = assert_bash_exec (
4260 bash ,
43- "_realcommand bin/arp" ,
61+ "__tester bin/arp" ,
4462 want_output = True ,
63+ want_newline = False ,
4564 )
4665 assert output .strip ().endswith ("/shared/bin/arp" )
4766
48- def test_relative_nonexistent (self , bash ):
67+ def test_relative_nonexistent (self , bash , functions ):
4968 output = assert_bash_exec (
5069 bash ,
51- "! _realcommand bin/non-existent" ,
70+ "! __tester bin/non-existent" ,
5271 want_output = False ,
5372 )
5473 assert output .strip () == ""
5574
56- def test_absolute (self , bash ):
75+ def test_absolute (self , bash , functions ):
5776 output = assert_bash_exec (
5877 bash ,
59- '_realcommand "$PWD/bin/arp"' ,
78+ '__tester "$PWD/bin/arp"' ,
6079 want_output = True ,
80+ want_newline = False ,
6181 )
6282 assert output .strip ().endswith ("/shared/bin/arp" )
6383
64- def test_absolute_nonexistent (self , bash ):
84+ def test_absolute_nonexistent (self , bash , functions ):
6585 output = assert_bash_exec (
6686 bash ,
67- '! _realcommand "$PWD/bin/non-existent"' ,
87+ '! __tester "$PWD/bin/non-existent"' ,
6888 want_output = False ,
6989 )
7090 assert output .strip () == ""
0 commit comments