@@ -202,6 +202,22 @@ def test_in_transaction_ro(self):
202
202
with self .assertRaises (AttributeError ):
203
203
self .cx .in_transaction = True
204
204
205
+
206
+ class SerializeTests (unittest .TestCase ):
207
+ def test_serialize_deserialize (self ):
208
+ with sqlite .connect (":memory:" ) as cx :
209
+ cx .execute ("create table t(t)" )
210
+ data , size = cx .serialize ()
211
+ cx .close ()
212
+
213
+ self .assertEqual (len (data ), size )
214
+
215
+ cx = sqlite .connect (":memory:" )
216
+ cx .deserialize (data )
217
+ cx .execute ("select t from t" )
218
+ cx .close ()
219
+
220
+
205
221
class OpenTests (unittest .TestCase ):
206
222
_sql = "create table test(id integer)"
207
223
@@ -649,6 +665,23 @@ def run(con, errors):
649
665
if len (errors ) > 0 :
650
666
self .fail ("\n " .join (errors ))
651
667
668
+ def test_con_serialize (self ):
669
+ def run (con , err ):
670
+ try :
671
+ con .serialize ()
672
+ err .append ("did not raise ProgrammingError" )
673
+ except sqlite .ProgrammingError :
674
+ pass
675
+ except :
676
+ err .append ("raised wrong exception" )
677
+
678
+ err = []
679
+ t = threading .Thread (target = run , kwargs = {"con" : self .con , "err" : err })
680
+ t .start ()
681
+ t .join ()
682
+ if len (err ) > 0 :
683
+ self .fail ("\n " .join (err ))
684
+
652
685
def test_cur_implicit_begin (self ):
653
686
def run (cur , errors ):
654
687
try :
@@ -986,6 +1019,7 @@ def suite():
986
1019
CursorTests ,
987
1020
ExtensionTests ,
988
1021
ModuleTests ,
1022
+ SerializeTests ,
989
1023
SqliteOnConflictTests ,
990
1024
ThreadTests ,
991
1025
]
0 commit comments