diff --git a/tests/utils.py b/tests/utils.py index f9e54c09d..48bb5edad 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,6 +8,8 @@ python -m unittest tests.utils.TestTicker """ +from unittest import TestSuite + # import pandas as pd # import numpy as np @@ -34,16 +36,16 @@ def test_storeTzNoRaise(self): tkr = 'AMZN' tz1 = "America/New_York" tz2 = "London/Europe" - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() cache.store(tkr, tz1) cache.store(tkr, tz2) def test_setTzCacheLocation(self): - self.assertEqual(yf.utils._DBManager.get_location(), self.tempCacheDir.name) + self.assertEqual(yf.cache._TzDBManager.get_location(), self.tempCacheDir.name) tkr = 'AMZN' tz1 = "America/New_York" - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() cache.store(tkr, tz1) self.assertTrue(os.path.exists(os.path.join(self.tempCacheDir.name, "tkr-tz.db"))) @@ -60,10 +62,10 @@ def test_tzCacheRootStore(self): tz1 = "America/New_York" # During attempt to store, will discover cannot write - yf.utils.get_tz_cache().store(tkr, tz1) + yf.cache.get_tz_cache().store(tkr, tz1) # Handling the store failure replaces cache with a dummy - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() self.assertTrue(cache.dummy) cache.store(tkr, tz1) @@ -71,19 +73,19 @@ def test_tzCacheRootLookup(self): # Test that if cache path in read-only filesystem, no exception. tkr = 'AMZN' # During attempt to lookup, will discover cannot write - yf.utils.get_tz_cache().lookup(tkr) + yf.cache.get_tz_cache().lookup(tkr) # Handling the lookup failure replaces cache with a dummy - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() self.assertTrue(cache.dummy) cache.lookup(tkr) def suite(): - suite = unittest.TestSuite() - suite.addTest(TestCache('Test cache')) - suite.addTest(TestCacheNoPermission('Test cache no permission')) - return suite + ts: TestSuite = unittest.TestSuite() + ts.addTest(TestCache('Test cache')) + ts.addTest(TestCacheNoPermission('Test cache no permission')) + return ts if __name__ == '__main__': diff --git a/yfinance/utils.py b/yfinance/utils.py index 53eac44a9..90d70136b 100644 --- a/yfinance/utils.py +++ b/yfinance/utils.py @@ -772,7 +772,7 @@ def fix_Yahoo_dst_issue(df, interval): f_pre_midnight = (df.index.minute == 0) & (df.index.hour.isin([22, 23])) dst_error_hours = _np.array([0] * df.shape[0]) dst_error_hours[f_pre_midnight] = 24 - df.index[f_pre_midnight].hour - df.index += _pd.TimedeltaIndex(dst_error_hours, 'h') + df.index += _pd.to_timedelta(dst_error_hours, 'h') return df