20
20
("manylinux2010" , "linux" , "linux" ),
21
21
],
22
22
)
23
- def test_environment_action (
23
+ def test_plat_environment_action (
24
24
monkeypatch : pytest .MonkeyPatch ,
25
25
environ : str | None ,
26
26
passed : str | None ,
@@ -45,6 +45,49 @@ def test_environment_action(
45
45
assert expected == args .PLAT
46
46
47
47
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
+
48
91
def test_environment_action_invalid_plat_env (monkeypatch : pytest .MonkeyPatch ) -> None :
49
92
choices = ["linux" , "manylinux1" , "manylinux2010" ]
50
93
monkeypatch .setenv ("AUDITWHEEL_PLAT" , "foo" )
@@ -61,7 +104,7 @@ def test_environment_action_invalid_plat_env(monkeypatch: pytest.MonkeyPatch) ->
61
104
62
105
63
106
def 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
65
108
monkeypatch .setenv ("AUDITWHEEL_ZIP_LEVEL" , "foo" )
66
109
p = argparse .ArgumentParser ()
67
110
with pytest .raises (argparse .ArgumentError ):
0 commit comments