(selenium)
| 1125 | |
| 1126 | @pytest.mark.xfail_browsers(safari="TODO: traceback is not exactly the same on Safari") |
| 1127 | def test_js_stackframes(selenium): |
| 1128 | res = selenium.run_js( |
| 1129 | """ |
| 1130 | self.b = function b(){ |
| 1131 | pyodide.pyimport("???"); |
| 1132 | } |
| 1133 | self.d1 = function d1(){ |
| 1134 | pyodide.runPython("c2()"); |
| 1135 | } |
| 1136 | self.d2 = function d2(){ |
| 1137 | d1(); |
| 1138 | } |
| 1139 | self.d3 = function d3(){ |
| 1140 | d2(); |
| 1141 | } |
| 1142 | self.d4 = function d4(){ |
| 1143 | d3(); |
| 1144 | } |
| 1145 | pyodide.runPython(` |
| 1146 | def c1(): |
| 1147 | from js import b |
| 1148 | b() |
| 1149 | def c2(): |
| 1150 | c1() |
| 1151 | def e(): |
| 1152 | from js import d4 |
| 1153 | from pyodide.ffi import to_js |
| 1154 | from traceback import extract_tb |
| 1155 | try: |
| 1156 | d4() |
| 1157 | except Exception as ex: |
| 1158 | return to_js([[x.filename, x.name] for x in extract_tb(ex.__traceback__)]) |
| 1159 | `); |
| 1160 | let e = pyodide.globals.get("e"); |
| 1161 | let res = e(); |
| 1162 | e.destroy(); |
| 1163 | return res; |
| 1164 | """ |
| 1165 | ) |
| 1166 | |
| 1167 | def normalize_tb(t): |
| 1168 | res = [] |
| 1169 | for [file, name] in t: |
| 1170 | if file.endswith((".js", ".html", ".mjs")): |
| 1171 | file = file.rpartition("/")[-1] |
| 1172 | if file.endswith(".py"): |
| 1173 | file = "/".join(file.split("/")[-2:]) |
| 1174 | if re.fullmatch(r"\:[0-9]*", file) or file in { |
| 1175 | "debugger eval code", |
| 1176 | "evalmachine.<anonymous>", |
| 1177 | }: |
| 1178 | file = "module_test.html" |
| 1179 | res.append([file, name]) |
| 1180 | return res |
| 1181 | |
| 1182 | frames = [ |
| 1183 | ["<exec>", "e"], |
| 1184 | ["module_test.html", "d4"], |
nothing calls this directly
no test coverage detected
searching dependent graphs…