|
| 1 | +From 38f7d1bd9869f7eeff41530e8e451caa026ef327 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Michael Simacek < [email protected]> |
| 3 | +Date: Mon, 14 Feb 2022 11:24:57 +0100 |
| 4 | +Subject: [PATCH] Adapt for GraalPython |
| 5 | + |
| 6 | +--- |
| 7 | + _pytest/_code/code.py | 20 +++++++++++--------- |
| 8 | + _pytest/assertion/__init__.py | 2 +- |
| 9 | + 2 files changed, 12 insertions(+), 10 deletions(-) |
| 10 | + |
| 11 | +diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py |
| 12 | +index 5b758a8..869ad4e 100644 |
| 13 | +--- a/_pytest/_code/code.py |
| 14 | ++++ b/_pytest/_code/code.py |
| 15 | +@@ -256,15 +256,17 @@ class TracebackEntry: |
| 16 | + if key is not None: |
| 17 | + astnode = astcache.get(key, None) |
| 18 | + start = self.getfirstlinesource() |
| 19 | +- try: |
| 20 | +- astnode, _, end = getstatementrange_ast( |
| 21 | +- self.lineno, source, astnode=astnode |
| 22 | +- ) |
| 23 | +- except SyntaxError: |
| 24 | +- end = self.lineno + 1 |
| 25 | +- else: |
| 26 | +- if key is not None and astcache is not None: |
| 27 | +- astcache[key] = astnode |
| 28 | ++ # GraalPython: no support for the ast module so the source cannot be retrieved correctly |
| 29 | ++ # try: |
| 30 | ++ # astnode, _, end = getstatementrange_ast( |
| 31 | ++ # self.lineno, source, astnode=astnode |
| 32 | ++ # ) |
| 33 | ++ # except SyntaxError: |
| 34 | ++ # end = self.lineno + 1 |
| 35 | ++ # else: |
| 36 | ++ # if key is not None and astcache is not None: |
| 37 | ++ # astcache[key] = astnode |
| 38 | ++ end = -1 |
| 39 | + return source[start:end] |
| 40 | + |
| 41 | + source = property(getsource) |
| 42 | +diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py |
| 43 | +index 480a26a..2466ea8 100644 |
| 44 | +--- a/_pytest/assertion/__init__.py |
| 45 | ++++ b/_pytest/assertion/__init__.py |
| 46 | +@@ -26,7 +26,7 @@ def pytest_addoption(parser: Parser) -> None: |
| 47 | + action="store", |
| 48 | + dest="assertmode", |
| 49 | + choices=("rewrite", "plain"), |
| 50 | +- default="rewrite", |
| 51 | ++ default="plain", |
| 52 | + metavar="MODE", |
| 53 | + help=( |
| 54 | + "Control assertion debugging tools.\n" |
| 55 | +-- |
| 56 | +2.34.1 |
| 57 | + |
0 commit comments