1- # Copyright (c) 2018, 2025 , Oracle and/or its affiliates. All rights reserved.
1+ # Copyright (c) 2018, 2026 , Oracle and/or its affiliates. All rights reserved.
22# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33#
44# The Universal Permissive License (UPL), Version 1.0
@@ -779,7 +779,6 @@ def test_annotations_in_function():
779779 exec (code ,test_globals )
780780 assert len (test_globals ['__annotations__' ]) == 0
781781 assert len (test_globals ['fn' ].__annotations__ ) == 0
782- assert 1 not in test_globals ['fn' ].__code__ .co_consts # the annotation is ignored in function
783782
784783 source = '''def fn():
785784 a:int =1
@@ -789,7 +788,6 @@ def test_annotations_in_function():
789788 assert len (test_globals ['__annotations__' ]) == 0
790789 assert hasattr (test_globals ['fn' ], '__annotations__' )
791790 assert len (test_globals ['fn' ].__annotations__ ) == 0
792- assert 1 in test_globals ['fn' ].__code__ .co_consts
793791
794792def test_annotations_in_class ():
795793
@@ -849,58 +847,6 @@ def test_annotations_in_class():
849847 assert test_globals ['Style' ].__annotations__ ['_path' ] == str
850848 assert '_path' in dir (test_globals ['Style' ])
851849
852- def test_negative_float ():
853-
854- def check_const (fn , expected ):
855- for const in fn .__code__ .co_consts :
856- if repr (const ) == repr (expected ):
857- return True
858- else :
859- return False
860-
861- def fn1 ():
862- return - 0.0
863-
864- assert check_const (fn1 , - 0.0 )
865-
866-
867- def find_count_in (collection , what ):
868- count = 0 ;
869- for item in collection :
870- if item == what :
871- count += 1
872- return count
873-
874- def test_same_consts ():
875- def fn1 (): a = 1 ; b = 1 ; return a + b
876- assert find_count_in (fn1 .__code__ .co_consts , 1 ) == 1
877-
878- def fn2 (): a = 'a' ; b = 'a' ; return a + b
879- assert find_count_in (fn2 .__code__ .co_consts , 'a' ) == 1
880-
881- def test_tuple_in_const ():
882- def fn1 () : return (0 ,)
883- assert (0 ,) in fn1 .__code__ .co_consts
884- assert 0 not in fn1 .__code__ .co_consts
885-
886- def fn2 () : return (1 , 2 , 3 , 1 , 2 , 3 )
887- assert (1 , 2 , 3 , 1 , 2 , 3 ) in fn2 .__code__ .co_consts
888- assert 1 not in fn2 .__code__ .co_consts
889- assert 2 not in fn2 .__code__ .co_consts
890- assert 3 not in fn2 .__code__ .co_consts
891- assert find_count_in (fn2 .__code__ .co_consts , (1 , 2 , 3 , 1 , 2 , 3 )) == 1
892-
893- def fn3 () : a = 1 ; return (1 , 2 , 1 )
894- assert (1 , 2 , 1 ) in fn3 .__code__ .co_consts
895- assert find_count_in (fn3 .__code__ .co_consts , 1 ) == 1
896- assert 2 not in fn3 .__code__ .co_consts
897-
898- def fn4 () : a = 1 ; b = (1 ,2 ,3 ); c = 4 ; return (1 , 2 , 3 , 1 , 2 , 3 )
899- assert (1 , 2 , 3 ) in fn4 .__code__ .co_consts
900- assert (1 , 2 , 3 , 1 , 2 , 3 ) in fn4 .__code__ .co_consts
901- assert 2 not in fn4 .__code__ .co_consts
902- assert find_count_in (fn4 .__code__ .co_consts , 1 ) == 1
903- assert find_count_in (fn4 .__code__ .co_consts , 4 ) == 1
904850
905851def test_ComprehensionGeneratorExpr ():
906852 def create_list (gen ):
0 commit comments