8000 Traceback test · sdpython/pythonnet@57769f1 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit 57769f1

Browse files
testrunner123filmor
authored andcommitted
Traceback test
1 parent 6befab6 commit 57769f1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/tests/test_subclass.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,39 @@ def test_derived_class():
128128
assert id(x) == id(ob)
129129

130130

131+
def test_derived_traceback():
132+
"""Test python exception traceback in class derived from managed base"""
133+
class DerivedClass(SubClassTest):
134+
__namespace__ = "Python.Test.traceback"
135+
136+
def foo(self):
137+
print (xyzname)
138+
return None
139+
140+
import sys,traceback
141+
ob = DerivedClass()
142+
143+
# direct call
144+
try:
145+
ob.foo()
146+
assert False
147+
except:
148+
e = sys.exc_info()
149+
assert "xyzname" in str(e[1])
150+
location = traceback.extract_tb(e[2], -1)[0]
151+
assert location[2] == "foo"
152+
153+
# call through managed code
154+
try:
155+
FunctionsTest.test_foo(ob)
156+
assert False
157+
except:
158+
e = sys.exc_info()
159+
assert "xyzname" in str(e[1])
160+
location = traceback.extract_tb(e[2], -1)[0]
161+
assert location[2] == "foo"
162+
163+
131164
def test_create_instance():
132165
"""Test derived instances can be created from managed code"""
133166
DerivedClass = derived_class_fixture(test_create_instance.__name__)

0 commit comments

Comments
 (0)
0