@@ -63,7 +63,67 @@ def pytest(**kwargs):
6363 attrs (** kwargs )
6464 packaging (** kwargs )
6565 py (** kwargs )
66- install_from_pypi ("pytest==5.0.1" , ** kwargs )
66+ patch = """
67+ diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py
68+ index aa4dcff..029e659 100644
69+ --- a/src/_pytest/_code/code.py
70+ +++ b/src/_pytest/_code/code.py
71+ @@ -211,15 +211,17 @@ class TracebackEntry:
72+ if key is not None:
73+ astnode = astcache.get(key, None)
74+ start = self.getfirstlinesource()
75+ - try:
76+ - astnode, _, end = getstatementrange_ast(
77+ - self.lineno, source, astnode=astnode
78+ - )
79+ - except SyntaxError:
80+ - end = self.lineno + 1
81+ - else:
82+ - if key is not None:
83+ - astcache[key] = astnode
84+ + end = -1
85+ + # GraalPython: no support for the ast module so the source cannot be retrieved correctly
86+ + # try:
87+ + # astnode, _, end = getstatementrange_ast(
88+ + # self.lineno, source, astnode=astnode
89+ + # )
90+ + # except SyntaxError:
91+ + # end = self.lineno + 1
92+ + # else:
93+ + # if key is not None:
94+ + # astcache[key] = astnode
95+ return source[start:end]
96+
97+ source = property(getsource)
98+ diff --git a/src/_pytest/python.py b/src/_pytest/python.py
99+ index 66d8530..8bb2ab6 100644
100+ --- a/src/_pytest/python.py
101+ +++ b/src/_pytest/python.py
102+ @@ -494,8 +494,10 @@ class Module(nodes.File, PyCollector):
103+ def _importtestmodule(self):
104+ # we assume we are only called once per module
105+ importmode = self.config.getoption("--import-mode")
106+ + imported = False
107+ try:
108+ mod = self.fspath.pyimport(ensuresyspath=importmode)
109+ + imported = True
110+ except SyntaxError:
111+ raise self.CollectError(
112+ _pytest._code.ExceptionInfo.from_current().getrepr(style="short")
113+ @@ -538,6 +540,10 @@ class Module(nodes.File, PyCollector):
114+ "or @pytest.mark.skipif decorators instead, and to skip a "
115+ "module use `pytestmark = pytest.mark.{skip,skipif}."
116+ )
117+ + finally:
118+ + # this is needed for GraalPython: some modules fail with java level exceptions (the finally block still executes)
119+ + if not imported:
120+ + raise self.CollectError("Module could not be imported, the test could be unsupported by GraalPython")
121+ self.config.pluginmanager.consider_module(mod)
122+ return mod
123+
124+
125+ """
126+ install_from_pypi ("pytest==5.0.1" , patch = patch , ** kwargs )
67127
68128 def py (** kwargs ):
69129 install_from_pypi ("py==1.8.0" , ** kwargs )
0 commit comments