aboutsummaryrefslogtreecommitdiff
path: root/tests/test_deprecated.py
blob: 6510c82b3f789bf9c322ac9ea5fcf138bb0fb552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import unittest
import warnings


class DeprecatedTest(unittest.TestCase):
    def test_cache(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.cache import Cache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.cache" in str(w[-1].message)

    def test_fifo(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.fifo import FIFOCache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.fifo" in str(w[-1].message)

    def test_lfu(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.lfu import LFUCache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.lfu" in str(w[-1].message)

    def test_lru(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.lru import LRUCache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.lru" in str(w[-1].message)

    def test_mru(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.mru import MRUCache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.mru" in str(w[-1].message)

    def test_rr(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.rr import RRCache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.rr" in str(w[-1].message)

    def test_ttl(self):
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            from cachetools.ttl import TTLCache

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert "cachetools.ttl" in str(w[-1].message)