MCPcopy Index your code
hub / github.com/python/cpython / assertInterpolationEqual

Method assertInterpolationEqual

Lib/test/test_string/_support.py:5–28  ·  view source on GitHub ↗

Test Interpolation equality. The *i* argument must be an Interpolation instance. The *exp* argument must be a tuple of the form (value, expression, conversion, format_spec) where the final three items may be omitted and are assumed to be '', None and '' respectively

(self, i, exp)

Source from the content-addressed store, hash-verified

3
4class TStringBaseCase:
5 def assertInterpolationEqual(self, i, exp):
6 """Test Interpolation equality.
7
8 The *i* argument must be an Interpolation instance.
9
10 The *exp* argument must be a tuple of the form
11 (value, expression, conversion, format_spec) where the final three
12 items may be omitted and are assumed to be '', None and '' respectively.
13 """
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, "")
29
30 def assertTStringEqual(self, t, strings, interpolations):
31 """Test template string literal equality.

Callers 2

assertTStringEqualMethod · 0.95

Calls 1

assertEqualMethod · 0.45

Tested by 1