summaryrefslogtreecommitdiff
path: root/tests/test_overrides.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:48:07 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:48:11 +0900
commit3b5dc6176476d5ed2313cd7185d985f47e225165 (patch)
treeaee8e1d1c516bf7528eceae708baecfe484baddc /tests/test_overrides.py
parentd80fc1d31f28c6bcf9ea34b253e8765321616c3c (diff)
downloadpygobject2-3b5dc6176476d5ed2313cd7185d985f47e225165.tar.gz
pygobject2-3b5dc6176476d5ed2313cd7185d985f47e225165.tar.bz2
pygobject2-3b5dc6176476d5ed2313cd7185d985f47e225165.zip
Imported Upstream version 3.7.2
Change-Id: I6fbadd2c5d032a44b4b424160cdbd0f097320457 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'tests/test_overrides.py')
-rw-r--r--tests/test_overrides.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index dd2aa6a..e1af1f1 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -4,6 +4,8 @@
import unittest
import gi.overrides
+import gi.module
+
try:
from gi.repository import Regress
Regress # pyflakes
@@ -27,3 +29,30 @@ class TestRegistry(unittest.TestCase):
# Regress override is in tests/gi/overrides, separate from gi/overrides
# https://bugzilla.gnome.org/show_bug.cgi?id=680913
self.assertEqual(Regress.REGRESS_OVERRIDE, 42)
+
+
+class TestModule(unittest.TestCase):
+ # Tests for gi.module
+
+ def test_get_introspection_module_caching(self):
+ # This test attempts to minimize side effects by
+ # using a DynamicModule directly instead of going though:
+ # from gi.repository import Foo
+
+ # Clear out introspection module cache before running this test.
+ old_modules = gi.module._introspection_modules
+ gi.module._introspection_modules = {}
+
+ mod_name = 'GIMarshallingTests'
+ mod1 = gi.module.get_introspection_module(mod_name)
+ mod2 = gi.module.get_introspection_module(mod_name)
+ self.assertTrue(mod1 is mod2)
+
+ # Using a DynamicModule will use get_introspection_module internally
+ # in its _load method.
+ mod_overridden = gi.module.DynamicModule(mod_name)
+ mod_overridden._load()
+ self.assertTrue(mod1 is mod_overridden._introspection_module)
+
+ # Restore the previous cache
+ gi.module._introspection_modules = old_modules