forked from pool/python-bpython
- Add fix-python313-tests.patch to fix tests under Python 3.13 OBS-URL: https://build.opensuse.org/request/show/1234587 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-bpython?expand=0&rev=34
74 lines
3.1 KiB
Diff
74 lines
3.1 KiB
Diff
From 45f4117b534d6827279f7b9e633f3cabe0fb37e6 Mon Sep 17 00:00:00 2001
|
|
From: Sebastian Ramacher <sebastian@ramacher.at>
|
|
Date: Fri, 25 Oct 2024 17:42:20 +0200
|
|
Subject: [PATCH] Fix test errors with Python 3.13
|
|
|
|
---
|
|
bpython/test/test_interpreter.py | 17 ++++++++++++++++-
|
|
bpython/test/test_repl.py | 11 ++++++++---
|
|
2 files changed, 24 insertions(+), 4 deletions(-)
|
|
|
|
Index: bpython-0.24/bpython/test/test_interpreter.py
|
|
===================================================================
|
|
--- bpython-0.24.orig/bpython/test/test_interpreter.py
|
|
+++ bpython-0.24/bpython/test/test_interpreter.py
|
|
@@ -112,7 +112,22 @@ class TestInterpreter(unittest.TestCase)
|
|
|
|
global_not_found = "name 'gfunc' is not defined"
|
|
|
|
- if (3, 11) <= sys.version_info[:2]:
|
|
+ if (3, 13) <= sys.version_info[:2]:
|
|
+ expected = (
|
|
+ "Traceback (most recent call last):\n File "
|
|
+ + green('"<input>"')
|
|
+ + ", line "
|
|
+ + bold(magenta("1"))
|
|
+ + ", in "
|
|
+ + cyan("<module>")
|
|
+ + "\n gfunc()"
|
|
+ + "\n ^^^^^\n"
|
|
+ + bold(red("NameError"))
|
|
+ + ": "
|
|
+ + cyan(global_not_found)
|
|
+ + "\n"
|
|
+ )
|
|
+ elif (3, 11) <= sys.version_info[:2]:
|
|
expected = (
|
|
"Traceback (most recent call last):\n File "
|
|
+ green('"<input>"')
|
|
Index: bpython-0.24/bpython/test/test_repl.py
|
|
===================================================================
|
|
--- bpython-0.24.orig/bpython/test/test_repl.py
|
|
+++ bpython-0.24/bpython/test/test_repl.py
|
|
@@ -338,9 +338,14 @@ class TestGetSource(unittest.TestCase):
|
|
self.assert_get_source_error_for_current_function(
|
|
collections.defaultdict.copy, "No source code found for INPUTLINE"
|
|
)
|
|
- self.assert_get_source_error_for_current_function(
|
|
- collections.defaultdict, "could not find class definition"
|
|
- )
|
|
+ if sys.version_info[:2] >= (3, 13):
|
|
+ self.assert_get_source_error_for_current_function(
|
|
+ collections.defaultdict, "source code not available"
|
|
+ )
|
|
+ else:
|
|
+ self.assert_get_source_error_for_current_function(
|
|
+ collections.defaultdict, "could not find class definition"
|
|
+ )
|
|
|
|
def test_current_line(self):
|
|
self.repl.interp.locals["a"] = socket.socket
|
|
Index: bpython-0.24/bpython/repl.py
|
|
===================================================================
|
|
--- bpython-0.24.orig/bpython/repl.py
|
|
+++ bpython-0.24/bpython/repl.py
|
|
@@ -152,7 +152,7 @@ class Interpreter(code.InteractiveInterp
|
|
with self.timer:
|
|
return super().runsource(source, filename, symbol)
|
|
|
|
- def showsyntaxerror(self, filename: Optional[str] = None) -> None:
|
|
+ def showsyntaxerror(self, filename: Optional[str] = None, source: Optional[str] = None) -> None:
|
|
"""Override the regular handler, the code's copied and pasted from
|
|
code.py, as per showtraceback, but with the syntaxerror callback called
|
|
and the text in a pretty colour."""
|