diff options
| author | Jörn Hees <joernhees@users.noreply.github.com> | 2015-11-28 12:25:01 +0100 |
|---|---|---|
| committer | Jörn Hees <joernhees@users.noreply.github.com> | 2015-11-28 12:25:01 +0100 |
| commit | c95649357e74be43b0f08bd7ec95c6b508a82544 (patch) | |
| tree | d450b011f3f85363cbd1f0669452e9d4baa3d7cd | |
| parent | e261af3995d86425a1444c7748db8e82abc620bb (diff) | |
| parent | 561d327e4443ecf0c6892dc6e4cc1831a73c5ce7 (diff) | |
| download | rdflib-c95649357e74be43b0f08bd7ec95c6b508a82544.tar.gz | |
Merge pull request #536 from pchampin/fix-issue-535
fixed issue #535
| -rw-r--r-- | rdflib/plugins/parsers/nquads.py | 4 | ||||
| -rw-r--r-- | test/test_issue535.py | 19 |
2 files changed, 21 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..15c6d0d3 --- /dev/null +++ b/test/test_issue535.py @@ -0,0 +1,19 @@ +from rdflib import ConjunctiveGraph, URIRef +from rdflib.parser import StringInputSource + +def test_nquads_default_graph(): + ds = ConjunctiveGraph() + + data = """ + <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(data=data, 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)) |
