@@ -11,23 +11,30 @@ def assertInterpolationEqual(self, i, exp):
1111 (value, expression, conversion, format_spec) where the final three
1212 items may be omitted and are assumed to be '', None and '' respectively.
1313 """
14- # Merge in defaults for expression, conversion, and format_spec
15- defaults = ('' , None , '' )
16- expected = exp + defaults [len (exp ) - 1 :]
17-
18- actual = (i .value , i .expression , i .conversion , i .format_spec )
19- self .assertEqual (actual , expected )
20-
14+ if len (exp ) == 4 :
15+ actual = (i .value , i .expression , i .conversion , i .format_spec )
16+ self .assertEqual (actual , exp )
17+ elif len (exp ) == 3 :
18+ self .assertEqual ((i .value , i .expression , i .conversion ), exp )
19+ self .assertEqual (i .format_spec , "" )
20+ elif len (exp ) == 2 :
21+ self .assertEqual ((i .value , i .expression ), exp )
22+ self .assertEqual (i .conversion , None )
23+ self .assertEqual (i .format_spec , "" )
24+ elif len (exp ) == 1 :
25+ self .assertEqual ((i .value ,), exp )
26+ self .assertEqual (i .expression , "" )
27+ self .assertEqual (i .conversion , None )
28+ self .assertEqual (i .format_spec , "" )
2129
2230 def assertTStringEqual (self , t , strings , interpolations ):
2331 """Test template string literal equality.
2432
2533 The *strings* argument must be a tuple of strings equal to *t.strings*.
2634
2735 The *interpolations* argument must be a sequence of tuples which are
28- compared against *t.interpolations*. Each tuple consists of
29- (value, expression, conversion, format_spec), though the final three
30- items may be omitted and are assumed to be '' None, and '' respectively.
36+ compared against *t.interpolations*. Each tuple must match the form
37+ described in the `assertInterpolationEqual` method.
3138 """
3239 self .assertEqual (t .strings , strings )
3340 self .assertEqual (len (t .interpolations ), len (interpolations ))
0 commit comments