File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1094,8 +1094,21 @@ def test_notebook_export_json_with_output():
10941094 expected = expected_nb ["cells" ][i ]
10951095 assert expected ["source" ] == command
10961096 assert actual ["source" ] == expected ["source" ]
1097- assert (
1098- actual ["outputs" ] == expected ["outputs" ]
1097+ _strip_ansi = re .compile (r"\x1b\[[0-9;]*m" ).sub
1098+
1099+ def strip_ansi_from_outputs (outputs ):
1100+ result = []
1101+ for out in outputs :
1102+ out = dict (out )
1103+ if "traceback" in out :
1104+ out ["traceback" ] = [
1105+ _strip_ansi ("" , line ) for line in out ["traceback" ]
1106+ ]
1107+ result .append (out )
1108+ return result
1109+
1110+ assert strip_ansi_from_outputs (actual ["outputs" ]) == strip_ansi_from_outputs (
1111+ expected ["outputs" ]
10991112 ), f"Outputs do not match for cell { i + 1 } with source { command !r} "
11001113 finally :
11011114 _ip .colors = "nocolor"
You can’t perform that action at this time.
0 commit comments