|
8 | 8 | python -m unittest tests.cache.TestCache |
9 | 9 |
|
10 | 10 | """ |
11 | | -from unittest import TestSuite |
12 | | - |
13 | 11 | from tests.context import yfinance as yf |
14 | 12 |
|
15 | 13 | import unittest |
@@ -48,46 +46,5 @@ def test_setTzCacheLocation(self): |
48 | 46 | self.assertTrue(os.path.exists(os.path.join(self.tempCacheDir.name, "tkr-tz.db"))) |
49 | 47 |
|
50 | 48 |
|
51 | | -class TestCacheNoPermission(unittest.TestCase): |
52 | | - @classmethod |
53 | | - def setUpClass(cls): |
54 | | - if os.name == "nt": # Windows |
55 | | - cls.cache_path = "C:\\Windows\\System32\\yf-cache" |
56 | | - else: # Unix/Linux/MacOS |
57 | | - # Use a writable directory |
58 | | - cls.cache_path = "/yf-cache" |
59 | | - yf.set_tz_cache_location(cls.cache_path) |
60 | | - |
61 | | - def test_tzCacheRootStore(self): |
62 | | - # Test that if cache path in read-only filesystem, no exception. |
63 | | - tkr = 'AMZN' |
64 | | - tz1 = "America/New_York" |
65 | | - |
66 | | - # During attempt to store, will discover cannot write |
67 | | - yf.cache.get_tz_cache().store(tkr, tz1) |
68 | | - |
69 | | - # Handling the store failure replaces cache with a dummy |
70 | | - cache = yf.cache.get_tz_cache() |
71 | | - self.assertTrue(cache.dummy) |
72 | | - cache.store(tkr, tz1) |
73 | | - |
74 | | - def test_tzCacheRootLookup(self): |
75 | | - # Test that if cache path in read-only filesystem, no exception. |
76 | | - tkr = 'AMZN' |
77 | | - # During attempt to lookup, will discover cannot write |
78 | | - yf.cache.get_tz_cache().lookup(tkr) |
79 | | - |
80 | | - # Handling the lookup failure replaces cache with a dummy |
81 | | - cache = yf.cache.get_tz_cache() |
82 | | - self.assertTrue(cache.dummy) |
83 | | - cache.lookup(tkr) |
84 | | - |
85 | | -def suite(): |
86 | | - ts: TestSuite = unittest.TestSuite() |
87 | | - ts.addTest(TestCache('Test cache')) |
88 | | - ts.addTest(TestCacheNoPermission('Test cache no permission')) |
89 | | - return ts |
90 | | - |
91 | | - |
92 | 49 | if __name__ == '__main__': |
93 | 50 | unittest.main() |
0 commit comments