@@ -3705,6 +3705,18 @@ def test_shared_memory_basics(self):
37053705 self .assertGreaterEqual (sms .size , 512 )
37063706 self .assertGreaterEqual (len (sms .buf ), sms .size )
37073707
3708+ # Verify __repr__
3709+ self .assertIn (sms .name , str (sms ))
3710+ self .assertIn (str (sms .size ), str (sms ))
3711+
3712+ # Test pickling
3713+ sms .buf [0 :6 ] = b'pickle'
3714+ pickled_sms = pickle .dumps (sms )
3715+ sms2 = pickle .loads (pickled_sms )
3716+ self .assertEqual (sms .name , sms2 .name )
3717+ self .assertEqual (sms .size , sms2 .size )
3718+ self .assertEqual (bytes (sms .buf [0 :6 ]), bytes (sms2 .buf [0 :6 ]), b'pickle' )
3719+
37083720 # Modify contents of shared memory segment through memoryview.
37093721 sms .buf [0 ] = 42
37103722 self .assertEqual (sms .buf [0 ], 42 )
@@ -3910,6 +3922,23 @@ def test_shared_memory_ShareableList_basics(self):
39103922 )
39113923 self .addCleanup (sl .shm .unlink )
39123924
3925+ # Verify __repr__
3926+ self .assertIn (sl .shm .name , str (sl ))
3927+ self .assertIn (str (list (sl )), str (sl ))
3928+
3929+ # Index Out of Range (get)
3930+ with self .assertRaises (IndexError ):
3931+ sl [7 ]
3932+
3933+ # Index Out of Range (set)
3934+ with self .assertRaises (IndexError ):
3935+ sl [7 ] = 2
3936+
3937+ # Assign value without format change (str -> str)
3938+ current_format = sl ._get_packing_format (0 )
3939+ sl [0 ] = 'howdy'
3940+ self .assertEqual (current_format , sl ._get_packing_format (0 ))
3941+
39133942 # Verify attributes are readable.
39143943 self .assertEqual (sl .format , '8s8sdqxxxxxx?xxxxxxxx?q' )
39153944
0 commit comments