@@ -92,6 +92,34 @@ def test_converter(self) -> None:
9292 x = o .converter (False )
9393 assert not x , f"converter returned False for { t !r} "
9494
95+ # When the variable is created with boolean string make sure the converter
96+ # returns the correct result i.e. a bool or a passed path
97+ opts = SCons .Variables .Variables ()
98+ opts .Add (SCons .Variables .PackageVariable ('test' , 'test build variable help' , 'yes' ))
99+ o = opts .options [0 ]
100+
101+ x = o .converter (str (True ))
102+ assert not isinstance (x , str ), "converter with default str(yes) returned a string when given str(True)"
103+ assert x , "converter with default str(yes) returned False for str(True)"
104+ x = o .converter (str (False ))
105+ assert not isinstance (x , str ), "converter with default str(yes) returned a string when given str(False)"
106+ assert not x , "converter with default str(yes) returned True for str(False)"
107+ x = o .converter ('/explicit/path' )
108+ assert x == '/explicit/path' , "converter with default str(yes) did not return path"
109+
110+ opts = SCons .Variables .Variables ()
111+ opts .Add (SCons .Variables .PackageVariable ('test' , 'test build variable help' , 'no' ))
112+ o = opts .options [0 ]
113+
114+ x = o .converter (str (True ))
115+ assert not isinstance (x , str ), "converter with default str(no) returned a string when given str(True)"
116+ assert x , "converter with default str(no) returned False for str(True)"
117+ x = o .converter (str (False ))
118+ assert not isinstance (x , str ), "converter with default str(no) returned a string when given str(False)"
119+ assert not x , "converter with default str(no) returned True for str(False)"
120+ x = o .converter ('/explicit/path' )
121+ assert x == '/explicit/path' , "converter with default str(no) did not return path"
122+
95123 def test_validator (self ) -> None :
96124 """Test the PackageVariable validator"""
97125 opts = SCons .Variables .Variables ()
0 commit comments