Skip to content

Commit 51fe510

Browse files
Fix: Make flaky magics dag test deterministic (#4334)
1 parent 25e6262 commit 51fe510

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

tests/integrations/jupyter/test_magics.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,23 @@ def test_run_dag(
324324
"'Executing model batches ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 18/18"
325325
)
326326
assert not output.stderr
327-
assert len(output.outputs) == 6
327+
328+
# At least 6 outputs expected as the number of models in the particular batch might vary
329+
assert len(output.outputs) >= 6
330+
328331
html_text_actual = convert_all_html_output_to_text(output)
329-
html_text_expected = [
330-
"[2K",
331-
"Executing model batches ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━ 93.8% • 15/16 • 0:00:",
332-
"[1/1] sushi.waiter_as_customer_by_day [insert 2023-01-01 - 2023-01-02, audits ✔2]",
333-
"",
334-
"✔ Model batches executed",
335-
"Run finished for environment 'prod'",
336-
]
337-
for txt_actual, txt_expected in zip(html_text_actual, html_text_expected):
338-
assert txt_actual.startswith(txt_expected)
332+
333+
# Check for key elements in the output
334+
assert any("[2K" in text for text in html_text_actual)
335+
assert any("Executing model batches" in text for text in html_text_actual)
336+
assert any("✔ Model batches executed" in text for text in html_text_actual)
337+
assert any("Run finished for environment 'prod'" in text for text in html_text_actual)
338+
339+
# Check the final messages
340+
final_outputs = [text for text in html_text_actual if text.strip()]
341+
assert final_outputs[-2] == "✔ Model batches executed"
342+
assert final_outputs[-1] == "Run finished for environment 'prod'"
343+
339344
actual_html_output = get_all_html_output(output)
340345
# Replace dynamic elapsed time with 00
341346
for i, chunk in enumerate(actual_html_output):

0 commit comments

Comments
 (0)