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