From 3b5dc6176476d5ed2313cd7185d985f47e225165 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 12 Jul 2017 08:48:07 +0900 Subject: Imported Upstream version 3.7.2 Change-Id: I6fbadd2c5d032a44b4b424160cdbd0f097320457 Signed-off-by: DongHun Kwak --- tests/test_overrides.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/test_overrides.py') 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 -- cgit v1.2.3