@@ -712,7 +712,14 @@ def test_primary_target_context(self):
712712 self .assertIsInstance (child .ctx , ast .Load )
713713
714714 def test_container_target_context (self ):
715- for expression in ('(a, [b, c])' , '[a, (b, c)]' , '((a))' , '()' , '[]' ):
715+ cases = (
716+ ('(a, [b, c])' , '(a, [b, c])' ),
717+ ('[a, (b, c)]' , '[a, (b, c)]' ),
718+ ('((a))' , 'a' ),
719+ ('()' , '()' ),
720+ ('[]' , '[]' ),
721+ )
722+ for expression , expected_segment in cases :
716723 for context in (ast .Load , ast .Store , ast .Del ):
717724 with self .subTest (expression = expression , context = context ):
718725 if context is ast .Load :
@@ -727,8 +734,7 @@ def test_container_target_context(self):
727734 if hasattr (child , 'ctx' ):
728735 self .assertIsInstance (child .ctx , context )
729736 self .assertEqual (ast .get_source_segment (source , node ),
730- ast .get_source_segment (expression ,
731- ast .parse (expression , mode = 'eval' ).body ))
737+ expected_segment )
732738
733739 node = ast .parse ('[a, *[b, *c]] = value' ).body [0 ].targets [0 ]
734740 for child in ast .walk (node ):
0 commit comments