Open s-kust opened 7 months ago
This works
python -m unittest tests.utils.TestCache
How about making all the tests work? Or remove outdated tests.
I'm suggesting they do work, if invoked correctly. Not sure why a different invocation fails.
I'm suggesting they do work, if invoked correctly. Not sure why a different invocation fails.
Perhaps it's time to update the contribution document.
The Unit Tests section of https://github.com/ranaroussi/yfinance/discussions/1084 gives people 4 commands to run tests with. None of them worked for me on a brand new clone of main (commit 9e2252e4516304efbd52d05ad66a5beb9a900e5e).
➜ git show --oneline --no-patch
9e2252e (HEAD -> main, tag: 0.2.44) Version 0.2.44
➜ py -m pip install -t requirements.txt
python -m unittest tests.test_prices
python -m unittest tests.test_prices.TestPriceRepair
python -m unittest tests.test_prices.TestPriceRepair.test_ticker_missing
python -m unittest discover -s tests
The first 3 lines run into ModuleNotFoundError: No module named 'requests_cache'
, not mentioned in requirements.txt. Fixing it runs into ModuleNotFoundError: No module named 'requests_ratelimiter'
.
Fixing this runs into AttributeError: module 'tests.test_prices' has no attribute 'TestPriceRepair'
.
Running the unittest discover command gives 4 relative import errors.
It'd be nice if there were actions to run builds to spot these issues.
Using Py 3.11.7
@antoniouaa I've updated #1084, and PR #2067 will fix python -m unittest discover -s tests
So has this fixed? because I'm still getting ModuleNotFoundError: No module named 'requests_cache'
.
I really would like to contribute. and I think tests are probably the best way to help others to contribute
Describe bug
Some of the tests that I managed to run locally fail. It is also not possible to run all tests with one command.
Simple code that reproduces your problem
kust@DESKTOP-JRMIVKT:~/yfinance$ python -m unittest discover tests
Ran 0 tests in 0.000s
kust@DESKTOP-JRMIVKT:~/yfinance$ python -m unittest tests.utils
sqlite3.OperationalError: unable to open database file
Debug log
kust@DESKTOP-JRMIVKT:~/yfinance$ python -m unittest tests.utils ..EE
ERROR: test_tzCacheRootLookup (tests.utils.TestCacheNoPermission)
Traceback (most recent call last): File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3232, in connect self._state.set_connection(self._connect()) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3576, in _connect conn = sqlite3.connect(self.database, timeout=self._timeout, sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3290, in execute_sql cursor = self.cursor() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3280, in cursor self.connect() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3231, in connect with __exception_wrapper: File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3059, in exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3232, in connect self._state.set_connection(self._connect()) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3576, in _connect conn = sqlite3.connect(self.database, timeout=self._timeout, peewee.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/kust/yfinance/tests/utils.py", line 76, in test_tzCacheRootLookup yf.cache.get_tz_cache().lookup(tkr) File "/home/kust/yfinance/yfinance/cache.py", line 169, in lookup return _KV.get(_KV.key == key).value File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 6805, in get return sq.get() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 7253, in get return clone.execute(database)[0] File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 2011, in inner return method(self, database, *args, *kwargs) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 2082, in execute return self._execute(database) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 2255, in _execute cursor = database.execute(self) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3299, in execute return self.execute_sql(sql, params) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3289, in execute_sql with __exception_wrapper: File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3059, in exit__ reraise(new_type, new_type(exc_value, exc_args), traceback) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3290, in execute_sql cursor = self.cursor() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3280, in cursor self.connect() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3231, in connect with __exception_wrapper: File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3059, in exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3232, in connect self._state.set_connection(self._connect()) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3576, in _connect conn = sqlite3.connect(self.database, timeout=self._timeout, peewee.OperationalError: unable to open database file
====================================================================== ERROR: test_tzCacheRootStore (tests.utils.TestCacheNoPermission)
Traceback (most recent call last): File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3232, in connect self._state.set_connection(self._connect()) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3576, in _connect conn = sqlite3.connect(self.database, timeout=self._timeout, sqlite3.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3290, in execute_sql cursor = self.cursor() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3280, in cursor self.connect() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3231, in connect with __exception_wrapper: File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3059, in exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3232, in connect self._state.set_connection(self._connect()) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3576, in _connect conn = sqlite3.connect(self.database, timeout=self._timeout, peewee.OperationalError: unable to open database file
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/kust/yfinance/tests/utils.py", line 65, in test_tzCacheRootStore yf.cache.get_tz_cache().store(tkr, tz1) File "/home/kust/yfinance/yfinance/cache.py", line 191, in store with db.atomic(): File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 4434, in enter return self._helper.enter() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 4469, in enter self._begin() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 4455, in _begin self.db.begin(*args, *kwargs) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3812, in begin self.execute_sql(statement) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3289, in execute_sql with __exception_wrapper: File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3059, in exit__ reraise(new_type, new_type(exc_value, exc_args), traceback) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3290, in execute_sql cursor = self.cursor() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3280, in cursor self.connect() File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3231, in connect with __exception_wrapper: File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3059, in exit__ reraise(new_type, new_type(exc_value, *exc_args), traceback) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 192, in reraise raise value.with_traceback(tb) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3232, in connect self._state.set_connection(self._connect()) File "/home/kust/.pyenv/versions/3.10.4/lib/python3.10/site-packages/peewee.py", line 3576, in _connect conn = sqlite3.connect(self.database, timeout=self._timeout, peewee.OperationalError: unable to open database file
Ran 4 tests in 0.119s
FAILED (errors=2)
Bad data proof
No response
yfinance
version0.2.37
Python version
No response
Operating system
Ubuntu for Windows