diff options
| author | Pierre-Antoine Champin <pchampin@liris.cnrs.fr> | 2015-10-29 11:42:54 +0000 |
|---|---|---|
| committer | Pierre-Antoine Champin <pchampin@liris.cnrs.fr> | 2015-10-29 11:42:54 +0000 |
| commit | c0484d137c79c79ae82f53c2b293bc0231d3b196 (patch) | |
| tree | 4ef9a1a86ed015af09ad60923e637c488b4159b3 | |
| parent | ad1ec4e81381175da2c834f9f40e7d0411dbc2c0 (diff) | |
| download | rdflib-c0484d137c79c79ae82f53c2b293bc0231d3b196.tar.gz | |
fixed issue #535
| -rw-r--r-- | rdflib/plugins/parsers/nquads.py | 4 | ||||
| -rw-r--r-- | test/test_issue535.py | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/rdflib/plugins/parsers/nquads.py b/rdflib/plugins/parsers/nquads.py index bcbd7b03..f733078f 100644 --- a/rdflib/plugins/parsers/nquads.py +++ b/rdflib/plugins/parsers/nquads.py @@ -45,7 +45,7 @@ class NQuadsParser(NTriplesParser): """Parse f as an N-Triples file.""" assert sink.store.context_aware, ("NQuadsParser must be given" " a context aware store.") - self.sink = ConjunctiveGraph(store=sink.store) + self.sink = ConjunctiveGraph(store=sink.store, identifier=sink.identifier) source = inputsource.getByteStream() @@ -81,7 +81,7 @@ class NQuadsParser(NTriplesParser): obj = self.object() self.eat(r_wspace) - context = self.uriref() or self.nodeid() + context = self.uriref() or self.nodeid() or self.sink.identifier self.eat(r_tail) if self.line: diff --git a/test/test_issue535.py b/test/test_issue535.py new file mode 100644 index 00000000..527c4296 --- /dev/null +++ b/test/test_issue535.py @@ -0,0 +1,18 @@ +from rdflib import ConjunctiveGraph, URIRef +from rdflib.parser import StringInputSource + +def test_nquads_default_graph(): + ds = ConjunctiveGraph() + + src = StringInputSource(""" + <http://example.org/s1> <http://example.org/p1> <http://example.org/o1> . + <http://example.org/s2> <http://example.org/p2> <http://example.org/o2> . + <http://example.org/s3> <http://example.org/p3> <http://example.org/o3> <http://example.org/g3> . + """) + + publicID = URIRef("http://example.org/g0") + ds.parse(src, format="nquads", publicID=publicID) + + assert len(ds) == 3, len(g) + assert len(list(ds.contexts())) == 2, len(list(ds.contexts())) + assert len(ds.get_context(publicID)) == 2, len(ds.get_context(publicID)) |
