コード例 #1
0
 def test_find_settings(self):
     # find_settings() returns a dict of settings from a Django-like
     # settings file. It excludes settings beginning with underscores.
     module = types.ModuleType("example")
     module.SETTING = factory.make_string()
     module._NOT_A_SETTING = factory.make_string()
     expected = {"SETTING": module.SETTING}
     observed = find_settings(module)
     self.assertEqual(expected, observed)
コード例 #2
0
 def test_import_settings(self):
     # import_settings() copies settings from another module into the
     # caller's global scope.
     source = types.ModuleType("source")
     source.SETTING = factory.make_string()
     target = types.ModuleType("target")
     target._source = source
     target._import_settings = import_settings
     eval("_import_settings(_source)", vars(target))
     expected = {"SETTING": source.SETTING}
     observed = find_settings(target)
     self.assertEqual(expected, observed)