ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.89k stars 2.44k forks source link

Tests failing #2112

Open dhruvan2006 opened 2 weeks ago

dhruvan2006 commented 2 weeks ago

Running python -m unittest discover -s tests from #1084 causes 5 failures and 1 error.

====================================================================== ERROR: test_resampling (test_price_repair.TestPriceRepairAssumptions.test_resampling)

Traceback (most recent call last): File "/home/dhruvan/yfinance/tests/test_price_repair.py", line 49, in test_resampling elif dfr.index[0] == df_truth.index[1]:


  File "/home/dhruvan/yfinance/.venv/lib/python3.12/site-packages/pandas/core/indexes/base.py", line 5389, in __getitem__
    return getitem(key)
           ^^^^^^^^^^^^
  File "/home/dhruvan/yfinance/.venv/lib/python3.12/site-packages/pandas/core/arrays/datetimelike.py", line 381, in __getitem__
    result = cast("Union[Self, DTScalarOrNaT]", super().__getitem__(key))
                                                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dhruvan/yfinance/.venv/lib/python3.12/site-packages/pandas/core/arrays/_mixins.py", line 284, in __getitem__
    result = self._ndarray[key]
             ~~~~~~~~~~~~~^^^^^
IndexError: index 1 is out of bounds for axis 0 with size 1

======================================================================
FAIL: test_repair_bad_div_adjusts (test_price_repair.TestPriceRepair.test_repair_bad_div_adjusts)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dhruvan/yfinance/tests/test_price_repair.py", line 668, in test_repair_bad_div_adjusts
    self.assertTrue(f_close.all())
AssertionError: np.False_ is not true

======================================================================
FAIL: test_repair_zeroes_daily (test_price_repair.TestPriceRepair.test_repair_zeroes_daily)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dhruvan/yfinance/tests/test_price_repair.py", line 384, in test_repair_zeroes_daily
    self.assertTrue(_np.isclose(repaired_df[c], correct_df[c], rtol=1e-8).all())
AssertionError: np.False_ is not true

======================================================================
FAIL: test_setTzCacheLocation (test_utils.TestCache.test_setTzCacheLocation)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dhruvan/yfinance/tests/test_utils.py", line 52, in test_setTzCacheLocation
    self.assertTrue(os.path.exists(os.path.join(self.tempCacheDir.name, "tkr-tz.db")))
AssertionError: False is not true

======================================================================
FAIL: test_tzCacheRootLookup (test_utils.TestCacheNoPermission.test_tzCacheRootLookup)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dhruvan/yfinance/tests/test_utils.py", line 81, in test_tzCacheRootLookup
    self.assertTrue(cache.dummy)
AssertionError: False is not true

======================================================================
FAIL: test_tzCacheRootStore (test_utils.TestCacheNoPermission.test_tzCacheRootStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dhruvan/yfinance/tests/test_utils.py", line 70, in test_tzCacheRootStore
    self.assertTrue(cache.dummy)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 109 tests in 308.065s

FAILED (failures=5, errors=1, skipped=2, expected failures=1)
ericpien commented 1 week ago

I ran into this too.

I think the first test_price_repair.TestPriceRepair.test_repair_bad_div_adjusts and test_price_repair.TestPriceRepair.test_repair_zeroes_daily are related to https://github.com/ranaroussi/yfinance/commit/8daa47716766cca2820b9bf78bb9f4487d387c7c as when I checkout the branch before that, it doesn't report the errors.

As for the test_utils cache test, it's harder to reproduce as it works on individual tests but fails when run under python -m unittest discover -s tests

ValueRaider commented 1 week ago

~If you can just ignore the repair-related tests, fail probably means I improved the algorithm but didn't update the test data.~

ValueRaider commented 4 days ago

There are real bugs in the repair logic, I'll handle.