Exemple #1
0
    def execute(self, test_case):
        with open(text_type(self['mf:action']), 'rb') as f:
            in_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))
        with test_case.assertRaises(Exception):
            turtle_parser.parse(in_data, base=base)
Exemple #2
0
    def execute(self, test_case):
        with open(text_type(self['mf:action']), 'rb') as f:
            in_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))
        with test_case.assertRaises(Exception):
            turtle_parser.parse(in_data, base=base)
Exemple #3
0
    def execute(self, test_case):
        with open(text_type(self['mf:action']), 'rb') as f:
            in_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))
        test_graph = turtle_parser.parse(in_data, base=base)
Exemple #4
0
    def execute(self, test_case):
        with open(text_type(self['mf:action']), 'rb') as f:
            in_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))
        test_graph = turtle_parser.parse(in_data, base=base)
Exemple #5
0
 def execute(self, entry):
     with open(unicode(entry['mf:action'].as_(Action)['qt:data']), 'r') as f:
         in_data = f.read()
     with open(unicode(entry['mf:result'])) as f:
         compare_data = f.read()
     test_graph = turtle_parser.parse(in_data)
     compare_graph = ntriples_parser.parse_string(compare_data)
Exemple #6
0
 def execute(self, entry):
     with open(unicode(entry['mf:action'].as_(Action)['qt:data']), 'r') as f:
         in_data = f.read()
         print in_data
     try:
         test_graph = turtle_parser.parse(in_data)
     except:
         pass
     else:
         self.fail('should not have parsed')
Exemple #7
0
    def execute(self, test_case):
        with open(text_type(self['mf:action']), 'rb') as f:
            in_data = f.read()

        with open(text_type(self['mf:result']), 'rb') as f:
            compare_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))

        test_graph = turtle_parser.parse(in_data, base=base)
        compare_graph = ntriples_parser.parse_string(compare_data)
        test_case.assertEqual(
            isomorph(test_graph),
            isomorph(compare_graph),
        )
Exemple #8
0
    def execute(self, test_case):
        with open(text_type(self['mf:action']), 'rb') as f:
            in_data = f.read()

        with open(text_type(self['mf:result']), 'rb') as f:
            compare_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))

        test_graph = turtle_parser.parse(in_data, base=base)
        compare_graph = ntriples_parser.parse_string(compare_data)
        test_case.assertEqual(
            isomorph(test_graph),
            isomorph(compare_graph),
        )
Exemple #9
0
 def __new__(mcs, name, bases, dict):
     manifest_name = dict['manifest']
     with open(manifest_name, 'r') as f:
         manifest_turtle = f.read()
     manifest_graph = turtle_parser.parse(manifest_turtle, base=dict['base'])
     manifest = Manifest(manifest_graph, dict['base'])
     entries = manifest['mf:entries'].as_(rdf.List)
     for entry in entries:
         entry = entry.as_(ManifestEntry)
         test_name = entry['mf:name'].value.replace('-', '_')
         if not test_name.startswith('test_'):
             test_name = 'test_' + test_name
         dict[test_name] = lambda self, entry=entry: self.execute(entry)
         # Doesn't look right in tracebacks, but looks fine in nose output.
         dict[test_name].func_name = test_name
     return type.__new__(mcs, name, bases, dict)
Exemple #10
0
            in_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))
        with test_case.assertRaises(Exception):
            turtle_parser.parse(in_data, base=base)


base = os.path.join(os.path.dirname(__file__), 'TurtleTests/')

manifest_name = os.path.join(base, 'manifest.ttl')

with open(manifest_name, 'rb') as f:
    manifest_turtle = f.read()

manifest_graph = turtle_parser.parse(manifest_turtle, base=base)

manifest = Manifest(manifest_graph, base)


class TurtleTests(unittest.TestCase):
    @classmethod
    def _make_test_case(cls, test_case):
        def test_method(self):
            return test_case.execute(self)

        test_name = 'test_' + test_case['mf:name'].value.replace('-', '_')
        test_method.__name__ = str(test_name)
        test_method.func_name = test_name.encode('utf8')
        test_method.func_doc = u'{} ({})'.format(
            test_case['rdfs:comment'].value,
Exemple #11
0
            in_data = f.read()

        base = urljoin(turtle_tests_url,
                       os.path.basename(text_type(self['mf:action'])))
        with test_case.assertRaises(Exception):
            turtle_parser.parse(in_data, base=base)


base = os.path.join(os.path.dirname(__file__), 'TurtleTests/')

manifest_name = os.path.join(base, 'manifest.ttl')

with open(manifest_name, 'rb') as f:
    manifest_turtle = f.read()

manifest_graph = turtle_parser.parse(manifest_turtle, base=base)

manifest = Manifest(manifest_graph, base)


class TurtleTests(unittest.TestCase):
    @classmethod
    def _make_test_case(cls, test_case):
        def test_method(self):
            return test_case.execute(self)

        test_name = 'test_' + test_case['mf:name'].value.replace('-', '_')
        test_method.__name__ = str(test_name)
        test_method.func_name = test_name.encode('utf8')
        test_method.func_doc = u'{} ({})'.format(
            test_case['rdfs:comment'].value,