Move test_parse.py and test_serialize.py into one file test_io.py. Use self.assertEqual instead of assert.
parent
f651af457f
commit
4f8f18afa8
@ -0,0 +1,44 @@ |
||||
import unittest |
||||
import io |
||||
|
||||
from pyoxigraph import * |
||||
|
||||
|
||||
class TestParse(unittest.TestCase): |
||||
def test_parse(self): |
||||
input = io.BytesIO(b'<foo> <p> "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'<http://example.com> <http://example.com/p> "1" .\n' |
||||
) |
@ -1,20 +0,0 @@ |
||||
import unittest |
||||
import io |
||||
|
||||
from pyoxigraph import * |
||||
|
||||
|
||||
class TestParse(unittest.TestCase): |
||||
def test_parse(self): |
||||
input = io.BytesIO(b'<foo> <p> "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") |
||||
), |
||||
) |
||||
] |
@ -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'<http://example.com> <http://example.com/p> "1" .\n' |
||||
) |
Loading…
Reference in new issue