Example #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")
Example #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'])
Example #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"])
Example #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['ほげ'])
Example #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")
Example #6
0
 def test_load_unavailable_extension(self):
     with self.assertRaisesRegexp(I18nFileLoadError, "no loader .*"):
         resource_loader.load_resource("foo.bar", "baz")
Example #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['ほげ'])
Example #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'])
Example #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")
Example #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")
Example #11
0
 def test_load_unavailable_extension(self):
     with self.assertRaisesRegexp(I18nFileLoadError, "no loader .*"):
         resource_loader.load_resource("foo.bar", "baz")