MCPcopy
hub / github.com/django/django / test_unicode

Method test_unicode

tests/cache/tests.py:533–560  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

531 self.assertIs(cache.touch("nonexistent"), False)
532
533 def test_unicode(self):
534 # Unicode values can be cached
535 stuff = {
536 "ascii": "ascii_value",
537 "unicode_ascii": "Iñtërnâtiônàlizætiøn1",
538 "Iñtërnâtiônàlizætiøn": "Iñtërnâtiônàlizætiøn2",
539 "ascii2": {"x": 1},
540 }
541 # Test `set`
542 for key, value in stuff.items():
543 with self.subTest(key=key):
544 cache.set(key, value)
545 self.assertEqual(cache.get(key), value)
546
547 # Test `add`
548 for key, value in stuff.items():
549 with self.subTest(key=key):
550 self.assertIs(cache.delete(key), True)
551 self.assertIs(cache.add(key, value), True)
552 self.assertEqual(cache.get(key), value)
553
554 # Test `set_many`
555 for key, value in stuff.items():
556 self.assertIs(cache.delete(key), True)
557 cache.set_many(stuff)
558 for key, value in stuff.items():
559 with self.subTest(key=key):
560 self.assertEqual(cache.get(key), value)
561
562 def test_binary_string(self):
563 # Binary strings should be cacheable

Callers

nothing calls this directly

Calls 6

itemsMethod · 0.45
setMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45
addMethod · 0.45
set_manyMethod · 0.45

Tested by

no test coverage detected