22
33import orjsonl
44from xopen import xopen
5+ import os
56
67data = [
78 {'hello' : 'world' },
1920
2021
2122
23+ def test_save () -> None :
24+ """Test the saving functionality of the orjsonl Python library."""
25+
26+ orjsonl .save ('test_orjsonl.jsonl' , data = data )
27+ with open ('test_orjsonl.jsonl' , 'r' , encoding = 'utf-8' ) as file :
28+ assert file .read () == jsonl
29+
30+ orjsonl .save ('test_orjsonl.jsonl.gz' , data = data )
31+ with xopen ('test_orjsonl.jsonl.gz' , 'r' , encoding = 'utf-8' ) as file :
32+ assert file .read () == jsonl
33+
34+
2235def test_stream () -> None :
2336 """Test the streaming functionality of the orjsonl Python library."""
2437
@@ -58,14 +71,5 @@ def test_append() -> None:
5871 with xopen ('test_orjsonl.jsonl.gz' , 'r' , encoding = 'utf-8' ) as file :
5972 assert file .read () == jsonl + '["a","b","c"]\n test\n {"lorem":"ipsum"}\n '
6073
61-
62- def test_save () -> None :
63- """Test the saving functionality of the orjsonl Python library."""
64-
65- orjsonl .save ('test_orjsonl.jsonl' , data = data )
66- with open ('test_orjsonl.jsonl' , 'r' , encoding = 'utf-8' ) as file :
67- assert file .read () == jsonl
68-
69- orjsonl .save ('test_orjsonl.jsonl.gz' , data = data )
70- with xopen ('test_orjsonl.jsonl.gz' , 'r' , encoding = 'utf-8' ) as file :
71- assert file .read () == jsonl
74+ os .remove ('test_orjsonl.jsonl' )
75+ os .remove ('test_orjsonl.jsonl.gz' )
0 commit comments