2020        ("manylinux2010" , "linux" , "linux" ), 
2121    ], 
2222) 
23- def  test_environment_action (
23+ def  test_plat_environment_action (
2424    monkeypatch : pytest .MonkeyPatch ,
2525    environ : str  |  None ,
2626    passed : str  |  None ,
@@ -45,6 +45,49 @@ def test_environment_action(
4545    assert  expected  ==  args .PLAT 
4646
4747
48+ _all_zip_level : list [int ] =  list (
49+     range (zlib .Z_NO_COMPRESSION , zlib .Z_BEST_COMPRESSION  +  1 )
50+ )
51+ 
52+ 
53+ @pytest .mark .parametrize ( 
54+     ("environ" , "passed" , "expected" ), 
55+     [ 
56+         (None , None , - 1 ), 
57+         (0 , None , 0 ), 
58+         (0 , 1 , 1 ), 
59+         (6 , 1 , 1 ), 
60+     ], 
61+ ) 
62+ def  test_zip_environment_action (
63+     monkeypatch : pytest .MonkeyPatch ,
64+     environ : int  |  None ,
65+     passed : int  |  None ,
66+     expected : int ,
67+ ) ->  None :
68+     choices  =  _all_zip_level 
69+     argv  =  []
70+     if  passed  is  not None :
71+         argv  =  ["--zip-level" , str (passed )]
72+     if  environ  is  not None :
73+         monkeypatch .setenv ("AUDITWHEEL_ZIP_LEVEL" , str (environ ))
74+     p  =  argparse .ArgumentParser ()
75+     p .add_argument (
76+         "-z" ,
77+         "--zip-level" ,
78+         action = EnvironmentDefault ,
79+         metavar = "zip" ,
80+         env = "AUDITWHEEL_ZIP_LEVEL" ,
81+         dest = "zip" ,
82+         type = int ,
83+         help = "Compress level to be used to create zip file." ,
84+         choices = choices ,
85+         default = zlib .Z_DEFAULT_COMPRESSION ,
86+     )
87+     args  =  p .parse_args (argv )
88+     assert  expected  ==  args .zip 
89+ 
90+ 
4891def  test_environment_action_invalid_plat_env (monkeypatch : pytest .MonkeyPatch ) ->  None :
4992    choices  =  ["linux" , "manylinux1" , "manylinux2010" ]
5093    monkeypatch .setenv ("AUDITWHEEL_PLAT" , "foo" )
@@ -61,7 +104,7 @@ def test_environment_action_invalid_plat_env(monkeypatch: pytest.MonkeyPatch) ->
61104
62105
63106def  test_environment_action_invalid_zip_env (monkeypatch : pytest .MonkeyPatch ) ->  None :
64-     choices  =  list ( range ( zlib . Z_NO_COMPRESSION ,  zlib . Z_BEST_COMPRESSION   +   1 )) 
107+     choices  =  _all_zip_level 
65108    monkeypatch .setenv ("AUDITWHEEL_ZIP_LEVEL" , "foo" )
66109    p  =  argparse .ArgumentParser ()
67110    with  pytest .raises (argparse .ArgumentError ):
0 commit comments