@@ -160,37 +160,37 @@ def test_type_is_configurable(self):
160
160
assert ph .check_needs_rehash (default_hash )
161
161
162
162
@mock .patch ("sys.platform" , "emscripten" )
163
- def test_params_on_wasm (self ):
163
+ @pytest .mark .parametrize ("machine" , ["wasm32" , "wasm64" ])
164
+ def test_params_on_wasm (self , machine ):
164
165
"""
165
166
Should fail if on wasm and parallelism > 1
166
167
"""
167
- for machine in ["wasm32" , "wasm64" ]:
168
- with mock .patch ("platform.machine" , return_value = machine ):
169
- with pytest .raises (
170
- UnsupportedParametersError ,
171
- match = "In WebAssembly environments `parallelism` must be 1." ,
172
- ):
173
- PasswordHasher (parallelism = 2 )
168
+ with mock .patch ("platform.machine" , return_value = machine ):
169
+ with pytest .raises (
170
+ UnsupportedParametersError ,
171
+ match = "In WebAssembly environments `parallelism` must be 1." ,
172
+ ):
173
+ PasswordHasher (parallelism = 2 )
174
174
175
- # last param is parallelism so it should fail
176
- params = Parameters (Type .I , 2 , 8 , 8 , 3 , 256 , 8 )
177
- with pytest .raises (
178
- UnsupportedParametersError ,
179
- match = "In WebAssembly environments `parallelism` must be 1." ,
180
- ):
181
- ph = PasswordHasher .from_parameters (params )
175
+ # last param is parallelism so it should fail
176
+ params = Parameters (Type .I , 2 , 8 , 8 , 3 , 256 , 8 )
177
+ with pytest .raises (
178
+ UnsupportedParametersError ,
179
+ match = "In WebAssembly environments `parallelism` must be 1." ,
180
+ ):
181
+ ph = PasswordHasher .from_parameters (params )
182
182
183
- # explicitly correct parameters
184
- ph = PasswordHasher (parallelism = 1 )
183
+ # explicitly correct parameters
184
+ ph = PasswordHasher (parallelism = 1 )
185
185
186
- hash = ph .hash ("hello" )
186
+ hash = ph .hash ("hello" )
187
187
188
- assert ph .verify (hash , "hello" ) is True
188
+ assert ph .verify (hash , "hello" ) is True
189
189
190
- # explicit, but still default parameters
191
- default_params = profiles .get_default_parameters ()
192
- ph = PasswordHasher .from_parameters (default_params )
190
+ # explicit, but still default parameters
191
+ default_params = profiles .get_default_parameters ()
192
+ ph = PasswordHasher .from_parameters (default_params )
193
193
194
- hash = ph .hash ("hello" )
194
+ hash = ph .hash ("hello" )
195
195
196
- assert ph .verify (hash , "hello" ) is True
196
+ assert ph .verify (hash , "hello" ) is True
0 commit comments