File: test_dotty_cache.py

package info (click to toggle)
dotty-dict 1.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 352 kB
  • sloc: python: 1,166; makefile: 192; sh: 5
file content (16 lines) | stat: -rw-r--r-- 410 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import unittest
from unittest.mock import MagicMock

from dotty_dict import dotty


class TestDottyCache(unittest.TestCase):

    def test_getitem_cache(self):
        dot = dotty()
        dot.__getitem__.cache_clear()
        dot._data = MagicMock()
        for _ in range(10):
            dot.get('x.y.z')
        self.assertEqual(dot.__getitem__.cache_info().hits, 9)
        dot.__getitem__.cache_clear()