From 4f8f18afa84feef529e67feb9c2d6c68ece9b0cc Mon Sep 17 00:00:00 2001 From: Edmond Date: Mon, 1 Aug 2022 02:37:30 +0000 Subject: [PATCH] Move test_parse.py and test_serialize.py into one file test_io.py. Use self.assertEqual instead of assert. --- python/tests/test_io.py | 44 ++++++++++++++++++++++++++++++++++ python/tests/test_parse.py | 20 ---------------- python/tests/test_serialize.py | 24 ------------------- 3 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 python/tests/test_io.py delete mode 100644 python/tests/test_parse.py delete mode 100644 python/tests/test_serialize.py diff --git a/python/tests/test_io.py b/python/tests/test_io.py new file mode 100644 index 00000000..d00c6d28 --- /dev/null +++ b/python/tests/test_io.py @@ -0,0 +1,44 @@ +import unittest +import io + +from pyoxigraph import * + + +class TestParse(unittest.TestCase): + def test_parse(self): + input = io.BytesIO(b'

"1" .') + result = list(parse(input, "text/turtle", base_iri="http://example.com/")) + + self.assertEqual( + result, + [ + Triple( + NamedNode("http://example.com/foo"), + NamedNode("http://example.com/p"), + Literal( + "1", + datatype=NamedNode("http://www.w3.org/2001/XMLSchema#string"), + ), + ) + ], + ) + + +class TestSerialize(unittest.TestCase): + def test_serialize(self): + output = io.BytesIO() + serialize( + [ + Triple( + NamedNode("http://example.com"), + NamedNode("http://example.com/p"), + Literal("1"), + ) + ], + output, + "text/turtle", + ) + + self.assertEqual( + output.getvalue(), b' "1" .\n' + ) diff --git a/python/tests/test_parse.py b/python/tests/test_parse.py deleted file mode 100644 index b017e49f..00000000 --- a/python/tests/test_parse.py +++ /dev/null @@ -1,20 +0,0 @@ -import unittest -import io - -from pyoxigraph import * - - -class TestParse(unittest.TestCase): - def test_parse(self): - input = io.BytesIO(b'

"1" .') - result = list(parse(input, "text/turtle", base_iri="http://example.com/")) - - assert result == [ - Triple( - NamedNode("http://example.com/foo"), - NamedNode("http://example.com/p"), - Literal( - "1", datatype=NamedNode("http://www.w3.org/2001/XMLSchema#string") - ), - ) - ] diff --git a/python/tests/test_serialize.py b/python/tests/test_serialize.py deleted file mode 100644 index 75ed73b7..00000000 --- a/python/tests/test_serialize.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest -import io - -from pyoxigraph import * - - -class TestSerialize(unittest.TestCase): - def test_serialize(self): - output = io.BytesIO() - serialize( - [ - Triple( - NamedNode("http://example.com"), - NamedNode("http://example.com/p"), - Literal("1"), - ) - ], - output, - "text/turtle", - ) - - assert ( - output.getvalue() == b' "1" .\n' - )