38
38
39
39
40
40
# Create new custom topic/subscription
41
- @pytest .fixture (scope = "module " )
41
+ @pytest .fixture (scope = "function " )
42
42
def topic_id ():
43
43
# Creates a pubsub topic, and tears it down.
44
44
publisher = google .cloud .pubsub .PublisherClient ()
@@ -53,7 +53,7 @@ def topic_id():
53
53
publisher .delete_topic (topic_path )
54
54
55
55
56
- @pytest .fixture (scope = "module " )
56
+ @pytest .fixture (scope = "function " )
57
57
def subscription_id (topic_id ):
58
58
# Subscribes to a topic.
59
59
subscriber = google .cloud .pubsub .SubscriberClient ()
@@ -160,7 +160,7 @@ def bigquery_project():
160
160
bigquery_client .delete_dataset (dataset_ref , delete_contents = True )
161
161
162
162
163
- @pytest .mark .flaky
163
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
164
164
def test_numerical_risk_analysis (
165
165
topic_id , subscription_id , bigquery_project , capsys
166
166
):
@@ -172,13 +172,14 @@ def test_numerical_risk_analysis(
172
172
NUMERIC_FIELD ,
173
173
topic_id ,
174
174
subscription_id ,
175
+ timeout = 30 ,
175
176
)
176
177
177
178
out , _ = capsys .readouterr ()
178
179
assert "Value Range:" in out
179
180
180
181
181
- @pytest .mark .flaky
182
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
182
183
def test_categorical_risk_analysis_on_string_field (
183
184
topic_id , subscription_id , bigquery_project , capsys
184
185
):
@@ -190,14 +191,14 @@ def test_categorical_risk_analysis_on_string_field(
190
191
UNIQUE_FIELD ,
191
192
topic_id ,
192
193
subscription_id ,
193
- timeout = 180 ,
194
+ timeout = 30 ,
194
195
)
195
196
196
197
out , _ = capsys .readouterr ()
197
198
assert "Most common value occurs" in out
198
199
199
200
200
- @pytest .mark .flaky
201
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
201
202
def test_categorical_risk_analysis_on_number_field (
202
203
topic_id , subscription_id , bigquery_project , capsys
203
204
):
@@ -209,13 +210,14 @@ def test_categorical_risk_analysis_on_number_field(
209
210
NUMERIC_FIELD ,
210
211
topic_id ,
211
212
subscription_id ,
213
+ timeout = 30 ,
212
214
)
213
215
214
216
out , _ = capsys .readouterr ()
215
217
assert "Most common value occurs" in out
216
218
217
219
218
- @pytest .mark .flaky
220
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
219
221
def test_k_anonymity_analysis_single_field (
220
222
topic_id , subscription_id , bigquery_project , capsys
221
223
):
@@ -227,6 +229,7 @@ def test_k_anonymity_analysis_single_field(
227
229
topic_id ,
228
230
subscription_id ,
229
231
[NUMERIC_FIELD ],
232
+ timeout = 30 ,
230
233
)
231
234
232
235
out , _ = capsys .readouterr ()
@@ -246,14 +249,15 @@ def test_k_anonymity_analysis_multiple_fields(
246
249
topic_id ,
247
250
subscription_id ,
248
251
[NUMERIC_FIELD , REPEATED_FIELD ],
252
+ timeout = 30 ,
249
253
)
250
254
251
255
out , _ = capsys .readouterr ()
252
256
assert "Quasi-ID values:" in out
253
257
assert "Class size:" in out
254
258
255
259
256
- @pytest .mark .flaky
260
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
257
261
def test_l_diversity_analysis_single_field (
258
262
topic_id , subscription_id , bigquery_project , capsys
259
263
):
@@ -266,6 +270,7 @@ def test_l_diversity_analysis_single_field(
266
270
subscription_id ,
267
271
UNIQUE_FIELD ,
268
272
[NUMERIC_FIELD ],
273
+ timeout = 30 ,
269
274
)
270
275
271
276
out , _ = capsys .readouterr ()
@@ -287,6 +292,7 @@ def test_l_diversity_analysis_multiple_field(
287
292
subscription_id ,
288
293
UNIQUE_FIELD ,
289
294
[NUMERIC_FIELD , REPEATED_FIELD ],
295
+ timeout = 30 ,
290
296
)
291
297
292
298
out , _ = capsys .readouterr ()
@@ -295,7 +301,7 @@ def test_l_diversity_analysis_multiple_field(
295
301
assert "Sensitive value" in out
296
302
297
303
298
- @pytest .mark .flaky
304
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
299
305
def test_k_map_estimate_analysis_single_field (
300
306
topic_id , subscription_id , bigquery_project , capsys
301
307
):
@@ -308,6 +314,7 @@ def test_k_map_estimate_analysis_single_field(
308
314
subscription_id ,
309
315
[NUMERIC_FIELD ],
310
316
["AGE" ],
317
+ timeout = 30 ,
311
318
)
312
319
313
320
out , _ = capsys .readouterr ()
@@ -329,6 +336,7 @@ def test_k_map_estimate_analysis_multiple_field(
329
336
subscription_id ,
330
337
[NUMERIC_FIELD , STRING_BOOLEAN_FIELD ],
331
338
["AGE" , "GENDER" ],
339
+ timeout = 30 ,
332
340
)
333
341
334
342
out , _ = capsys .readouterr ()
@@ -337,7 +345,7 @@ def test_k_map_estimate_analysis_multiple_field(
337
345
assert "Values" in out
338
346
339
347
340
- @pytest .mark .flaky
348
+ @pytest .mark .flaky ( max_runs = 3 , min_passes = 1 )
341
349
def test_k_map_estimate_analysis_quasi_ids_info_types_equal (
342
350
topic_id , subscription_id , bigquery_project
343
351
):
@@ -351,4 +359,5 @@ def test_k_map_estimate_analysis_quasi_ids_info_types_equal(
351
359
subscription_id ,
352
360
[NUMERIC_FIELD , STRING_BOOLEAN_FIELD ],
353
361
["AGE" ],
362
+ timeout = 30 ,
354
363
)
0 commit comments