Ejemplo n.º 1
0
    def inspect_syntax(self):
        result = []
        validator = self.get_schema_validator()

        for e in validator.iter_errors(self.spec):
            spec_path = ''
            schema_path = ''

            for s in list(e.absolute_path):
                spec_path += ('[' + str(s) +
                              ']' if isinstance(s, int) else '.' +
                              s if spec_path else s)

            for s in list(e.absolute_schema_path):
                schema_path += ('[' + str(s) +
                                ']' if isinstance(s, int) else '.' +
                                s if schema_path else s)

            entry = {
                'message': strings_utils.unescape(e.message),
                'spec_path': spec_path or None,
                'schema_path': schema_path or None
            }

            result.append(entry)

        return result
Ejemplo n.º 2
0
    def inspect_syntax(self):
        result = []
        validator = self.get_schema_validator()

        for e in validator.iter_errors(self.spec):
            spec_path = ""
            schema_path = ""

            for s in list(e.absolute_path):
                spec_path += (
                    "[" + str(s) + "]" if isinstance(s, int) else "." + s if spec_path else s
                )

            for s in list(e.absolute_schema_path):
                schema_path += (
                    "[" + str(s) + "]" if isinstance(s, int) else "." + s if schema_path else s
                )

            entry = {
                "message": str_util.unescape(e.message),
                "spec_path": spec_path or None,
                "schema_path": schema_path or None,
            }

            result.append(entry)

        return result
Ejemplo n.º 3
0
 def test_unescape(self):
     self.assertEqual(str_util.unescape('foobar'), 'foobar')
     self.assertEqual(str_util.unescape('\\\\foobar'), '\\foobar')
Ejemplo n.º 4
0
 def test_unescape(self):
     self.assertEqual(str_util.unescape("foobar"), "foobar")
     self.assertEqual(str_util.unescape("\\\\foobar"), "\\foobar")