MCPcopy
hub / github.com/pyodide/pyodide / test_runpython_filename

Function test_runpython_filename

src/tests/test_pyodide.py:1964–2009  ·  view source on GitHub ↗
(selenium, run_python)

Source from the content-addressed store, hash-verified

1962 "run_python", ["pyodide.runPython", "await pyodide.runPythonAsync"]
1963)
1964def test_runpython_filename(selenium, run_python):
1965 msg = selenium.run_js(
1966 """
1967 try {
1968 %s(`
1969 def f1():
1970 f2()
1971
1972 def f2():
1973 raise Exception("oops")
1974
1975 f1()
1976 `, {filename: "a.py"});
1977 } catch(e) {
1978 return e.message
1979 }
1980 """
1981 % run_python
1982 )
1983 expected = dedent(
1984 """\
1985 File "a.py", line 3, in f1
1986 f2()
1987
1988 File "a.py", line 6, in f2
1989 raise Exception("oops")
1990 ^^^^^^^^^^^^^^^
1991 """
1992 ).strip()
1993
1994 assert dedent("\n".join(msg.splitlines()[-7:-1])) == expected
1995 msg = selenium.run_js(
1996 """
1997 let f1;
1998 try {
1999 f1 = pyodide.globals.get("f1");
2000 f1();
2001 } catch(e) {
2002 console.log(e);
2003 return e.message;
2004 } finally {
2005 f1.destroy();
2006 }
2007 """
2008 )
2009 assert dedent("\n".join(msg.splitlines()[1:-1])) == expected
2010
2011
2012@pytest.mark.requires_dynamic_linking

Callers

nothing calls this directly

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…