예제 #1
0
 def test_serialization_twoway(self, tmpfile, obj):
     # these objects should survive a round-trip through the store
     with JSONDict(tmpfile) as dic:
         dic['obj'] = obj
     with JSONDict(tmpfile) as dic:
         assert dic['obj'] == obj
예제 #2
0
 def test_async_context(self, tmpfile):
     with JSONDict(tmpfile, sync=False) as dic:
         dic['obj'] = True
         assert 'obj' not in JSONDict(tmpfile)
     assert 'obj' in JSONDict(tmpfile)
예제 #3
0
 def test_sync(self, tmpfile):
     dic = JSONDict(tmpfile, sync=True)
     dic.update({'obj1': True, 'obj2': True, 'obj3': True, 'obj4': True})
     assert dic == JSONDict(tmpfile)
     dic['obj1'] = False
     assert dic == JSONDict(tmpfile)
     del dic['obj1']
     assert dic == JSONDict(tmpfile)
     dic.pop('obj2')
     assert dic == JSONDict(tmpfile)
     dic.popitem()
     assert dic == JSONDict(tmpfile)
     dic.clear()
     assert dic == JSONDict(tmpfile)
예제 #4
0
 def test_async_close(self, tmpfile):
     dic = JSONDict(tmpfile, sync=False)
     dic['obj'] = True
     assert 'obj' not in JSONDict(tmpfile)
     dic.close()
     assert 'obj' in JSONDict(tmpfile)
예제 #5
0
 def test_serialization_oneway(self, tmpfile, obj):
     # these objects should not raise any exceptions when stored
     with JSONDict(tmpfile) as dic:
         dic['obj'] = obj
     assert 'obj' in JSONDict(tmpfile)