Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Traceback test
  • Loading branch information
testrunner123 authored and filmor committed Nov 14, 2018
commit 57769f12727e2eb455cf51f3a4c731e25172b12a
33 changes: 33 additions & 0 deletions src/tests/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,39 @@ def test_derived_class():
assert id(x) == id(ob)


def test_derived_traceback():
"""Test python exception traceback in class derived from managed base"""
class DerivedClass(SubClassTest):
__namespace__ = "Python.Test.traceback"

def foo(self):
print (xyzname)
return None

import sys,traceback
ob = DerivedClass()

# direct call
try:
ob.foo()
assert False
except:
e = sys.exc_info()
assert "xyzname" in str(e[1])
location = traceback.extract_tb(e[2], -1)[0]
assert location[2] == "foo"

# call through managed code
try:
FunctionsTest.test_foo(ob)
assert False
except:
e = sys.exc_info()
assert "xyzname" in str(e[1])
location = traceback.extract_tb(e[2], -1)[0]
assert location[2] == "foo"


def test_create_instance():
"""Test derived instances can be created from managed code"""
DerivedClass = derived_class_fixture(test_create_instance.__name__)
Expand Down