|
| 1 | +diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py |
| 2 | +index 219ebb68f..b0d093f0e 100644 |
| 3 | +--- a/_pytest/_code/code.py |
| 4 | ++++ b/_pytest/_code/code.py |
| 5 | +@@ -224,15 +224,17 @@ class TracebackEntry: |
| 6 | + if key is not None: |
| 7 | + astnode = astcache.get(key, None) |
| 8 | + start = self.getfirstlinesource() |
| 9 | +- try: |
| 10 | +- astnode, _, end = getstatementrange_ast( |
| 11 | +- self.lineno, source, astnode=astnode |
| 12 | +- ) |
| 13 | +- except SyntaxError: |
| 14 | +- end = self.lineno + 1 |
| 15 | +- else: |
| 16 | +- if key is not None: |
| 17 | +- astcache[key] = astnode |
| 18 | ++ end = -1 |
| 19 | ++ # GraalPython: no support for the ast module so the source cannot be retrieved correctly |
| 20 | ++ # try: |
| 21 | ++ # astnode, _, end = getstatementrange_ast( |
| 22 | ++ # self.lineno, source, astnode=astnode |
| 23 | ++ # ) |
| 24 | ++ # except SyntaxError: |
| 25 | ++ # end = self.lineno + 1 |
| 26 | ++ # else: |
| 27 | ++ # if key is not None: |
| 28 | ++ # astcache[key] = astnode |
| 29 | + return source[start:end] |
| 30 | + |
| 31 | + source = property(getsource) |
| 32 | +diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py |
| 33 | +index 64d2267e7..760df1e49 100644 |
| 34 | +--- a/_pytest/assertion/__init__.py |
| 35 | ++++ b/_pytest/assertion/__init__.py |
| 36 | +@@ -28,7 +28,7 @@ def pytest_addoption(parser: Parser) -> None: |
| 37 | + action="store", |
| 38 | + dest="assertmode", |
| 39 | + choices=("rewrite", "plain"), |
| 40 | +- default="rewrite", |
| 41 | ++ default="plain", |
| 42 | + metavar="MODE", |
| 43 | + help=( |
| 44 | + "Control assertion debugging tools.\n" |
| 45 | +diff --git a/_pytest/python.py b/_pytest/python.py |
| 46 | +index aa8171486..d241aa459 100644 |
| 47 | +--- a/_pytest/python.py |
| 48 | ++++ b/_pytest/python.py |
| 49 | +@@ -548,8 +548,10 @@ class Module(nodes.File, PyCollector): |
| 50 | + def _importtestmodule(self): |
| 51 | + # we assume we are only called once per module |
| 52 | + importmode = self.config.getoption("--import-mode") |
| 53 | ++ imported = False |
| 54 | + try: |
| 55 | + mod = import_path(self.fspath, mode=importmode) |
| 56 | ++ imported = True |
| 57 | + except SyntaxError as e: |
| 58 | + raise self.CollectError( |
| 59 | + ExceptionInfo.from_current().getrepr(style="short") |
| 60 | +@@ -589,6 +591,10 @@ class Module(nodes.File, PyCollector): |
| 61 | + "or @pytest.mark.skipif decorators instead, and to skip a " |
| 62 | + "module use `pytestmark = pytest.mark.{skip,skipif}." |
| 63 | + ) from e |
| 64 | ++ finally: |
| 65 | ++ # this is needed for GraalPython: some modules fail with java level exceptions (the finally block still executes) |
| 66 | ++ if not imported: |
| 67 | ++ raise self.CollectError("Module could not be imported, the test could be unsupported by GraalPython") |
| 68 | + self.config.pluginmanager.consider_module(mod) |
| 69 | + return mod |
| 70 | + |
0 commit comments