| 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 |