Prefilter some hypothesis candidate lists before sampling
Marco Ricci

Marco Ricci commited on 2025-01-25 22:10:20
Zeige 2 geänderte Dateien mit 15 Einfügungen und 9 Löschungen.


Filtering the candidate lists *after* sampling requires redraws, all of
which are completely avoidable.
... ...
@@ -1030,9 +1030,11 @@ class TestCLI:
1030 1030
     @tests.hypothesis_settings_coverage_compatible_with_caplog
1031 1031
     @hypothesis.given(
1032 1032
         conf=tests.smudged_vault_test_config(
1033
-            strategies.sampled_from(TEST_CONFIGS).filter(
1034
-                tests.is_valid_test_config
1035
-            )
1033
+            strategies.sampled_from([
1034
+                conf
1035
+                for conf in tests.TEST_CONFIGS
1036
+                if tests.is_valid_test_config(conf)
1037
+            ])
1036 1038
         )
1037 1039
     )
1038 1040
     def test_213a_import_config_success(
... ...
@@ -118,9 +118,11 @@ def test_200_is_vault_config(test_config: tests.VaultTestConfig) -> None:
118 118
 @tests.hypothesis_settings_coverage_compatible
119 119
 @hypothesis.given(
120 120
     test_config=tests.smudged_vault_test_config(
121
-        config=strategies.sampled_from(tests.TEST_CONFIGS).filter(
122
-            tests.is_valid_test_config
123
-        )
121
+        config=strategies.sampled_from([
122
+            conf
123
+            for conf in tests.TEST_CONFIGS
124
+            if tests.is_valid_test_config(conf)
125
+        ])
124 126
     )
125 127
 )
126 128
 def test_200a_is_vault_config_smudged(
... ...
@@ -184,9 +186,11 @@ def test_400_validate_vault_config(test_config: tests.VaultTestConfig) -> None:
184 186
 @tests.hypothesis_settings_coverage_compatible
185 187
 @hypothesis.given(
186 188
     test_config=tests.smudged_vault_test_config(
187
-        config=strategies.sampled_from(tests.TEST_CONFIGS).filter(
188
-            tests.is_smudgable_vault_test_config
189
-        )
189
+        config=strategies.sampled_from([
190
+            conf
191
+            for conf in tests.TEST_CONFIGS
192
+            if tests.is_smudgable_vault_test_config(conf)
193
+        ])
190 194
     )
191 195
 )
192 196
 def test_400a_validate_vault_config_smudged(
193 197