1import unittest
2import warnings
3
4
5class DeprecatedTest(unittest.TestCase):
6    def test_cache(self):
7        with warnings.catch_warnings(record=True) as w:
8            warnings.simplefilter("always")
9            from cachetools.cache import Cache
10
11            assert len(w) == 1
12            assert issubclass(w[-1].category, DeprecationWarning)
13            assert "cachetools.cache" in str(w[-1].message)
14
15    def test_fifo(self):
16        with warnings.catch_warnings(record=True) as w:
17            warnings.simplefilter("always")
18            from cachetools.fifo import FIFOCache
19
20            assert len(w) == 1
21            assert issubclass(w[-1].category, DeprecationWarning)
22            assert "cachetools.fifo" in str(w[-1].message)
23
24    def test_lfu(self):
25        with warnings.catch_warnings(record=True) as w:
26            warnings.simplefilter("always")
27            from cachetools.lfu import LFUCache
28
29            assert len(w) == 1
30            assert issubclass(w[-1].category, DeprecationWarning)
31            assert "cachetools.lfu" in str(w[-1].message)
32
33    def test_lru(self):
34        with warnings.catch_warnings(record=True) as w:
35            warnings.simplefilter("always")
36            from cachetools.lru import LRUCache
37
38            assert len(w) == 1
39            assert issubclass(w[-1].category, DeprecationWarning)
40            assert "cachetools.lru" in str(w[-1].message)
41
42    def test_mru(self):
43        with warnings.catch_warnings(record=True) as w:
44            warnings.simplefilter("always")
45            from cachetools.mru import MRUCache
46
47            assert len(w) == 1
48            assert issubclass(w[-1].category, DeprecationWarning)
49            assert "cachetools.mru" in str(w[-1].message)
50
51    def test_rr(self):
52        with warnings.catch_warnings(record=True) as w:
53            warnings.simplefilter("always")
54            from cachetools.rr import RRCache
55
56            assert len(w) == 1
57            assert issubclass(w[-1].category, DeprecationWarning)
58            assert "cachetools.rr" in str(w[-1].message)
59
60    def test_ttl(self):
61        with warnings.catch_warnings(record=True) as w:
62            warnings.simplefilter("always")
63            from cachetools.ttl import TTLCache
64
65            assert len(w) == 1
66            assert issubclass(w[-1].category, DeprecationWarning)
67            assert "cachetools.ttl" in str(w[-1].message)
68