test_question='The Ulimate Question of Life, the Universe and Everything'test_answer=42

[docs]deftest_pickleCol():setupClass(SOTestPickle)connection=SOTestPickle._connectiontest=SOTestPickle(question=test_question,answer=test_answer)pickle_data=pickle.dumps(test,pickle.HIGHEST_PROTOCOL)connection.cache.clear()test=pickle.loads(pickle_data)test2=connection.cache.tryGet(test.id,SOTestPickle)asserttest2istestasserttest.question==test_questionasserttest.answer==test_answerif(connection.dbName=='sqlite')andconnection._memory:pytest.skip("The following test requires a different connection")test=SOTestPickle.get(test.id,# make a different DB URI and open another connectionconnection=getConnection(registry=''))raises(pickle.PicklingError,pickle.dumps,test,pickle.HIGHEST_PROTOCOL)