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

Method test_pickle_template

Lib/test/test_string/test_templatelib.py:104–123  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

102 self.assertEqual(t.values, ("Lys", 0, "GR"))
103
104 def test_pickle_template(self):
105 user = 'test'
106 for template in (
107 t'',
108 t"No values",
109 t'With inter {user}',
110 t'With ! {user!r}',
111 t'With format {1 / 0.3:.2f}',
112 Template(),
113 Template('a'),
114 Template(Interpolation('Nikita', 'name', None, '')),
115 Template('a', Interpolation('Nikita', 'name', 'r', '')),
116 ):
117 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
118 with self.subTest(proto=proto, template=template):
119 pickled = pickle.dumps(template, protocol=proto)
120 unpickled = pickle.loads(pickled)
121
122 self.assertEqual(unpickled.values, template.values)
123 self.assertEqual(fstring(unpickled), fstring(template))
124
125 def test_pickle_interpolation(self):
126 for interpolation in (

Callers

nothing calls this directly

Calls 7

fstringFunction · 0.90
TemplateClass · 0.85
InterpolationClass · 0.85
subTestMethod · 0.45
dumpsMethod · 0.45
loadsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected