Esempio n. 1
0
 def test_init_invalid_resource(self):
     """
     If no parser cannot be found for the translated resource,
     raise a ParseError.
     """
     path = self.get_invalid_file_path()
     with pytest.raises(ParseError):
         compare_locales.CompareLocalesResource(path, source_resource=None)
Esempio n. 2
0
 def test_init_missing_resource(self):
     """
     If the translated resource doesn't exist and no source resource is
     given, raise a ParseError.
     """
     path = self.get_nonexistant_file_path()
     with pytest.raises(ParseError):
         compare_locales.CompareLocalesResource(path, source_resource=None)
Esempio n. 3
0
    def get_nonexistant_file_resource(self, path):
        contents = dedent(
            """<?xml version="1.0" encoding="utf-8"?>
            <resources>
                <string name="source-string">Source String</string>
            </resources>
        """
        )

        source_path = create_named_tempfile(
            contents, prefix="strings", suffix=".xml", directory=self.tempdir,
        )
        source_resource = compare_locales.CompareLocalesResource(source_path)

        return compare_locales.CompareLocalesResource(
            path, source_resource=source_resource,
        )