Skip to content

Commit 7420856

Browse files
committed
Handle changed output in Python 3.11
1 parent 9e32826 commit 7420856

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

bpython/test/test_interpreter.py

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,35 @@ def gfunc():
112112

113113
global_not_found = "name 'gfunc' is not defined"
114114

115-
expected = (
116-
"Traceback (most recent call last):\n File "
117-
+ green('"<input>"')
118-
+ ", line "
119-
+ bold(magenta("1"))
120-
+ ", in "
121-
+ cyan("<module>")
122-
+ "\n gfunc()\n"
123-
+ bold(red("NameError"))
124-
+ ": "
125-
+ cyan(global_not_found)
126-
+ "\n"
127-
)
115+
if (3, 11) <= sys.version_info[:2]:
116+
expected = (
117+
"Traceback (most recent call last):\n File "
118+
+ green('"<input>"')
119+
+ ", line "
120+
+ bold(magenta("1"))
121+
+ ", in "
122+
+ cyan("<module>")
123+
+ "\n gfunc()"
124+
+ "\n ^^^^^\n"
125+
+ bold(red("NameError"))
126+
+ ": "
127+
+ cyan(global_not_found)
128+
+ "\n"
129+
)
130+
else:
131+
expected = (
132+
"Traceback (most recent call last):\n File "
133+
+ green('"<input>"')
134+
+ ", line "
135+
+ bold(magenta("1"))
136+
+ ", in "
137+
+ cyan("<module>")
138+
+ "\n gfunc()\n"
139+
+ bold(red("NameError"))
140+
+ ": "
141+
+ cyan(global_not_found)
142+
+ "\n"
143+
)
128144

129145
self.assertMultiLineEqual(str(plain("").join(a)), str(expected))
130146
self.assertEqual(plain("").join(a), expected)

0 commit comments

Comments
 (0)