summaryrefslogtreecommitdiff
path: root/test/test_issues
diff options
context:
space:
mode:
authorTom Mitchell <tcmitchell@users.noreply.github.com>2022-06-24 15:40:54 -0400
committerGitHub <noreply@github.com>2022-06-24 21:40:54 +0200
commiteabab5f2bf03e53ce72f039065fec60ae4e7bcc8 (patch)
tree63754bf2b8af0ce016ee73ea2f7d1f89ad4e8b09 /test/test_issues
parent4f96f468451bac36e7f606d238376b4025dd6897 (diff)
downloadrdflib-eabab5f2bf03e53ce72f039065fec60ae4e7bcc8.tar.gz
Remove extra newline from N-Triples output (#1999)
Remove the extra newline generated by the N-Triples serializer and add a unit test to verify that N-Triples output does not end in two consecutive newlines. Closes #1998
Diffstat (limited to 'test/test_issues')
-rw-r--r--test/test_issues/test_issue1998.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_issues/test_issue1998.py b/test/test_issues/test_issue1998.py
new file mode 100644
index 00000000..e3f28a39
--- /dev/null
+++ b/test/test_issues/test_issue1998.py
@@ -0,0 +1,15 @@
+"""Test that N-Triples formats do not have double newlines at the end
+of the output.
+
+https://github.com/RDFLib/rdflib/issues/1998
+"""
+import rdflib
+
+
+def test_1998():
+ g = rdflib.Graph()
+ bob = rdflib.URIRef("http://example.org/people/Bob")
+ g.add((bob, rdflib.RDF.type, rdflib.FOAF.Person))
+ for nt_format in ("nt", "nt11"):
+ output = g.serialize(format=nt_format)
+ assert not output.endswith("\n\n")