@@ -725,6 +725,39 @@ def test_user_exception(self):
725725 ])
726726
727727
728+ class CodeTests (_GetXIDataTests ):
729+
730+ MODE = 'code'
731+
732+ def test_function_code (self ):
733+ self .assert_roundtrip_equal_not_identical ([
734+ * (f .__code__ for f in defs .FUNCTIONS ),
735+ * (f .__code__ for f in defs .FUNCTION_LIKE ),
736+ ])
737+
738+ def test_functions (self ):
739+ self .assert_not_shareable ([
740+ * defs .FUNCTIONS ,
741+ * defs .FUNCTION_LIKE ,
742+ ])
743+
744+ def test_other_objects (self ):
745+ self .assert_not_shareable ([
746+ None ,
747+ True ,
748+ False ,
749+ Ellipsis ,
750+ NotImplemented ,
751+ 9999 ,
752+ 'spam' ,
753+ b'spam' ,
754+ (),
755+ [],
756+ {},
757+ object (),
758+ ])
759+
760+
728761class ShareableTypeTests (_GetXIDataTests ):
729762
730763 MODE = 'xidata'
@@ -817,6 +850,13 @@ def test_object(self):
817850 object (),
818851 ])
819852
853+ def test_code (self ):
854+ # types.CodeType
855+ self .assert_not_shareable ([
856+ * (f .__code__ for f in defs .FUNCTIONS ),
857+ * (f .__code__ for f in defs .FUNCTION_LIKE ),
858+ ])
859+
820860 def test_function_object (self ):
821861 for func in defs .FUNCTIONS :
822862 assert type (func ) is types .FunctionType , func
@@ -935,12 +975,6 @@ def test_builtin_objects(self):
935975 self .assert_not_shareable ([
936976 types .MappingProxyType ({}),
937977 types .SimpleNamespace (),
938- # types.CodeType
939- defs .spam_minimal .__code__ ,
940- defs .spam_full .__code__ ,
941- defs .spam_CC .__code__ ,
942- defs .eggs_closure_C .__code__ ,
943- defs .ham_C_closure .__code__ ,
944978 # types.CellType
945979 types .CellType (),
946980 # types.FrameType
0 commit comments