MCPcopy Index your code
hub / github.com/bpython/bpython / test_traceback

Method test_traceback

bpython/test/test_interpreter.py:89–149  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 self.assertEqual(plain("").join(a), expected)
88
89 def test_traceback(self):
90 i = Interpreter()
91
92 def f():
93 return 1 / 0
94
95 def gfunc():
96 return f()
97
98 i.runsource("gfunc()")
99
100 global_not_found = "name 'gfunc' is not defined"
101
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]:
118 expected = (
119 "Traceback (most recent call last):\n File "
120 + green('"<input>"')
121 + ", line "
122 + bold(magenta("1"))
123 + ", in "
124 + cyan("<module>")
125 + "\n gfunc()"
126 + "\n ^^^^^\n"
127 + bold(red("NameError"))
128 + ": "
129 + cyan(global_not_found)
130 + "\n"
131 )
132 else:
133 expected = (
134 "Traceback (most recent call last):\n File "
135 + green('"<input>"')
136 + ", line "
137 + bold(magenta("1"))
138 + ", in "
139 + cyan("<module>")
140 + "\n gfunc()\n"
141 + bold(red("NameError"))
142 + ": "
143 + cyan(global_not_found)
144 + "\n"
145 )
146

Callers

nothing calls this directly

Calls 2

runsourceMethod · 0.95
InterpreterClass · 0.70

Tested by

no test coverage detected