Coverage for tdom / utils_test.py: 100%

23 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-17 23:32 +0000

1from .utils import CachableTemplate, LastUpdatedOrderedDict 

2 

3 

4def test_last_updated_ordered_dict() -> None: 

5 loudict: dict[int, str] = LastUpdatedOrderedDict() 

6 loudict[1] = "one" 

7 loudict[2] = "two" 

8 loudict[3] = "three" 

9 assert list(loudict.keys()) == [1, 2, 3] 

10 

11 loudict[2] = "TWO" 

12 assert list(loudict.keys()) == [1, 3, 2] 

13 

14 loudict[1] = "ONE" 

15 assert list(loudict.keys()) == [3, 2, 1] 

16 

17 loudict[4] = "four" 

18 assert list(loudict.keys()) == [3, 2, 1, 4] 

19 

20 

21def test_cachable_template_eq() -> None: 

22 t1 = CachableTemplate(t"Hello {'name'}!") 

23 t2 = CachableTemplate(t"Hello {'name'}!") 

24 t3 = CachableTemplate(t"Goodbye {'name'}!") 

25 

26 assert t1 == t2 

27 assert t1 != t3 

28 

29 

30def test_cachable_template_hash() -> None: 

31 t1 = CachableTemplate(t"Hello {'name'}!") 

32 t2 = CachableTemplate(t"Hello {'name'}!") 

33 

34 assert hash(t1) == hash(t2)