示例#1
0
 def test_load_wrong_json_file(self):
     resource_loader.init_json_loader()
     with self.assertRaisesRegexp(I18nFileLoadError,
                                  "error getting data .*"):
         resource_loader.load_resource(
             os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.json"),
             "foo")
示例#2
0
 def test_load_python_file(self):
     resource_loader.init_python_loader()
     data = resource_loader.load_resource(
         os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.py"),
         "settings")
     self.assertIn("foo", data)
     self.assertEqual("bar", data['foo'])
示例#3
0
 def test_load_yaml_file(self):
     resource_loader.init_yaml_loader()
     data = resource_loader.load_resource(
         os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.yml"),
         "settings")
     self.assertIn("foo", data)
     self.assertEqual("bar", data["foo"])
示例#4
0
 def test_load_file_with_strange_encoding(self):
     resource_loader.init_json_loader()
     config.set("encoding", "euc-jp")
     data = resource_loader.load_resource(
         os.path.join(RESOURCE_FOLDER, "settings", "eucjp_config.json"),
         "settings")
     self.assertIn("ほげ", data)
     self.assertEqual("ホゲ", data['ほげ'])
示例#5
0
 def test_register_yaml_loader(self):
     resource_loader.init_yaml_loader()
     with self.assertRaisesRegexp(I18nFileLoadError,
                                  "error loading file .*"):
         resource_loader.load_resource("foo.yml", "bar")
示例#6
0
 def test_load_unavailable_extension(self):
     with self.assertRaisesRegexp(I18nFileLoadError, "no loader .*"):
         resource_loader.load_resource("foo.bar", "baz")
示例#7
0
 def test_load_file_with_strange_encoding(self):
     resource_loader.init_json_loader()
     config.set("encoding", "euc-jp")
     data = resource_loader.load_resource(os.path.join(RESOURCE_FOLDER, "settings", "eucjp_config.json"), "settings")
     self.assertIn("ほげ", data)
     self.assertEqual("ホゲ", data['ほげ'])
示例#8
0
 def test_load_python_file(self):
     resource_loader.init_python_loader()
     data = resource_loader.load_resource(os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.py"), "settings")
     self.assertIn("foo", data)
     self.assertEqual("bar", data['foo'])
示例#9
0
 def test_load_wrong_json_file(self):
     resource_loader.init_json_loader()
     with self.assertRaisesRegexp(I18nFileLoadError, "error getting data .*"):
         resource_loader.load_resource(os.path.join(RESOURCE_FOLDER, "settings", "dummy_config.json"), "foo")
示例#10
0
 def test_register_yaml_loader(self):
     resource_loader.init_yaml_loader()
     with self.assertRaisesRegexp(I18nFileLoadError, "error loading file .*"):
         resource_loader.load_resource("foo.yml", "bar")
示例#11
0
 def test_load_unavailable_extension(self):
     with self.assertRaisesRegexp(I18nFileLoadError, "no loader .*"):
         resource_loader.load_resource("foo.bar", "baz")