MCPcopy
hub / github.com/django/django / test_lazy_format

Method test_lazy_format

tests/utils_tests/test_functional.py:243–252  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

241 self.assertEqual(lazy_a() * lazy_5(), "aaaaa")
242
243 def test_lazy_format(self):
244 class QuotedString(str):
245 def __format__(self, format_spec):
246 value = super().__format__(format_spec)
247 return f"“{value}”"
248
249 lazy_f = lazy(lambda: QuotedString("Hello!"), QuotedString)
250 self.assertEqual(format(lazy_f(), ""), "“Hello!”")
251 f = lazy_f()
252 self.assertEqual(f"I said, {f}", "I said, “Hello!”")
253
254 def test_lazy_equality(self):
255 """

Callers

nothing calls this directly

Calls 3

lazyFunction · 0.90
QuotedStringClass · 0.85
formatFunction · 0.50

Tested by

no test coverage detected