Skip to content

Commit

Permalink
Unit test to show that without repyportability, dylink's module cache…
Browse files Browse the repository at this point in the history
… provides the same module instance (and thus correct instance of an imported exception class) to each importer of that module. Contrast with portability/tests/ut_portability_catch_nestedimported_exception.py, and SeattleTestbed/portability#28.
  • Loading branch information
aaaaalbert committed Jun 20, 2014
1 parent d61bc6f commit 8ae85a4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/ut_seattlelib_dylink_catch_nestedimport_exception.r2py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Verify that we can catch an excpetion defined in an imported library
and raised in another.
"""
#pragma repy restrictions.test dylink.r2py
#pragma out Successfully caught Lib1Error().

lib1 = dy_import_module("portability_testlib1.r2py") # defines the exception
lib2 = dy_import_module("portability_testlib2.r2py") # raises it

try:
lib2.raise_lib1error()
except lib1.Lib1Error:
log("Successfully caught Lib1Error().\n")
except Exception, e:
log("Error: Expected Lib1Error() with id " + str(id(lib1.Lib1Error)) +
" but caught '" + repr(e) + "' with id " + str(id(e)) + " \n")

0 comments on commit 8ae85a4

Please sign in to comment.