OLD | NEW |
(Empty) | |
| 1 import unittest |
| 2 import pickle |
| 3 |
| 4 from common import MTurkCommon |
| 5 |
| 6 class TestHITPersistence(MTurkCommon): |
| 7 def create_hit_result(self): |
| 8 return self.conn.create_hit( |
| 9 question=self.get_question(), **self.get_hit_params() |
| 10 ) |
| 11 |
| 12 def test_pickle_hit_result(self): |
| 13 result = self.create_hit_result() |
| 14 new_result = pickle.loads(pickle.dumps(result)) |
| 15 |
| 16 def test_pickle_deserialized_version(self): |
| 17 """ |
| 18 It seems the technique used to store and reload the object must |
| 19 result in an equivalent object, or subsequent pickles may fail. |
| 20 This tests a double-pickle to elicit that error. |
| 21 """ |
| 22 result = self.create_hit_result() |
| 23 new_result = pickle.loads(pickle.dumps(result)) |
| 24 pickle.dumps(new_result) |
| 25 |
| 26 if __name__ == '__main__': |
| 27 unittest.main() |
OLD | NEW |