Skip to content

Commit 45f4117

Browse files
committed
Fix test errors with Python 3.13
1 parent 52a7a15 commit 45f4117

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

bpython/test/test_interpreter.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,22 @@ def gfunc():
9999

100100
global_not_found = "name 'gfunc' is not defined"
101101

102-
if (3, 11) <= sys.version_info[:2]:
102+
if (3, 13) <= sys.version_info[:2]:
103+
expected = (
104+
"Traceback (most recent call last):\n File "
105+
+ green('"<input>"')
106+
+ ", line "
107+
+ bold(magenta("1"))
108+
+ ", in "
109+
+ cyan("<module>")
110+
+ "\n gfunc()"
111+
+ "\n ^^^^^\n"
112+
+ bold(red("NameError"))
113+
+ ": "
114+
+ cyan(global_not_found)
115+
+ "\n"
116+
)
117+
elif (3, 11) <= sys.version_info[:2]:
103118
expected = (
104119
"Traceback (most recent call last):\n File "
105120
+ green('"<input>"')

bpython/test/test_repl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,14 @@ def test_current_function_cpython(self):
332332
self.assert_get_source_error_for_current_function(
333333
collections.defaultdict.copy, "No source code found for INPUTLINE"
334334
)
335-
self.assert_get_source_error_for_current_function(
336-
collections.defaultdict, "could not find class definition"
337-
)
335+
if sys.version_info[:2] >= (3, 13):
336+
self.assert_get_source_error_for_current_function(
337+
collections.defaultdict, "source code not available"
338+
)
339+
else:
340+
self.assert_get_source_error_for_current_function(
341+
collections.defaultdict, "could not find class definition"
342+
)
338343

339344
def test_current_line(self):
340345
self.repl.interp.locals["a"] = socket.socket

0 commit comments

Comments
 (0)