[issue45125] Improve tests and docs of how `pickle` works with `SharedMemory` obejcts

Serhiy Storchaka report at bugs.python.org
Tue Sep 7 06:36:08 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Go ahead. Fix also other issues in tests:

* All pickling tests should test with all supported protocols, not just with the default one.

* self.assertTrue(
            isinstance(deserialized_sl, shared_memory.ShareableList)
        )
assertIsinstance() can be used here.

* self.assertTrue(deserialized_sl[-1], 9)
What is this? If it tests that deserialized_sl[-1] is true, 9 should be removed. Should it be assertEqual() instead?

* self.assertFalse(sl is deserialized_sl)
assertIs() can be used here.

* self.assertTrue(len(serialized_sl) == len(serialized_larger_sl))
assertEqual() can be used here.

* All close() should either be called in the finally block, or registered with addCleanup(). Otherwise we will heave resource leaks if tests fail.

There may be other issues in other tests. Seems these tests need a clean up.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45125>
_______________________________________


More information about the Python-bugs-list mailing list