You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am running some pytests for my humblDATA package. I am using a few bob calls to get financial data, and I am running into an unclosed file error:
To Reproduce
Anytime I use a function that imports obb
Screenshots
===========================================================FAILURES============================================================_________________________________________________test_humblobject_availability_________________________________________________cls=<class'_pytest.runner.CallInfo'>, func=<functioncall_and_report.<locals>.<lambda>at0x30f039580>, when='call'reraise= (<class'_pytest.outcomes.Exit'>, <class'KeyboardInterrupt'>)
@classmethoddeffrom_call(
cls,
func: Callable[[], TResult],
when: Literal["collect", "setup", "call", "teardown"],
reraise: Optional[
Union[Type[BaseException], Tuple[Type[BaseException], ...]]
] =None,
) ->"CallInfo[TResult]":
"""Call func, wrapping the result in a CallInfo. :param func: The function to call. Called without arguments. :param when: The phase in which the function is called. :param reraise: Exception or exceptions that shall propagate if raised by the function, instead of being wrapped in the CallInfo. """excinfo=Nonestart=timing.time()
precise_start=timing.perf_counter()
try:
>result: Optional[TResult] =func()
menv/lib/python3.11/site-packages/_pytest/runner.py:341:
_________________________________________________________________menv/lib/python3.11/site-packages/_pytest/runner.py:241: in<lambda>lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraisemenv/lib/python3.11/site-packages/pluggy/_hooks.py:513: in__call__returnself._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
menv/lib/python3.11/site-packages/pluggy/_manager.py:120: in_hookexecreturnself._inner_hookexec(hook_name, methods, kwargs, firstresult)
menv/lib/python3.11/site-packages/_pytest/threadexception.py:87: inpytest_runtest_callyieldfromthread_exception_runtest_hook()
menv/lib/python3.11/site-packages/_pytest/threadexception.py:63: inthread_exception_runtest_hookyieldmenv/lib/python3.11/site-packages/_pytest/unraisableexception.py:90: inpytest_runtest_callyieldfromunraisable_exception_runtest_hook()
_________________________________________________________________defunraisable_exception_runtest_hook() ->Generator[None, None, None]:
withcatch_unraisable_exception() ascm:
try:
yieldfinally:
ifcm.unraisable:
ifcm.unraisable.err_msgisnotNone:
err_msg=cm.unraisable.err_msgelse:
err_msg="Exception ignored in"msg=f"{err_msg}: {cm.unraisable.object!r}\n\n"msg+="".join(
traceback.format_exception(
cm.unraisable.exc_type,
cm.unraisable.exc_value,
cm.unraisable.exc_traceback,
)
)
>warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
Epytest.PytestUnraisableExceptionWarning: Exceptionignoredin: <_io.FileIO [closed]>EETraceback (mostrecentcalllast):
EFile"/Users/jjfantini/github/humblFINANCE-org/humblDATA/menv/lib/python3.11/site-packages/openbb_econdb/utils/helpers.py", line269, in<module>ESYMBOL_TO_INDICATOR=json.load(
E^^^^^^^^^^EResourceWarning: unclosedfile<_io.TextIOWrappername='/Users/jjfantini/github/humblFINANCE-org/humblDATA/menv/lib/python3.11/site-packages/openbb_econdb/utils/symbol_to_indicator.json'mode='r'encoding='UTF-8'>menv/lib/python3.11/site-packages/_pytest/unraisableexception.py:80: PytestUnraisableExceptionWarning-------------------generatedxmlfile: /Users/jjfantini/github/humblFINANCE-org/humblDATA/reports/pytest.xml-------------------====================================================shorttestsummaryinfo====================================================FAILEDtests/unittests/core/standard_models/abstract/test_humblobject.py::test_humblobject_availability-pytest.PytestUnraisableExceptionWarning: Exceptionignoredin: <_io.FileIO [closed]>Traceback (mostrecentcalllast):
File"/Users/jjfantini/github/humblFINANCE-org/humblDATA/menv/lib/python3.11/site-packages/openbb_econdb/utils/helpers.py", line269, in<module>SYMBOL_TO_INDICATOR=json.load(
^^^^^^^^^^ResourceWarning: unclosedfile<_io.TextIOWrappername='/Users/jjfantini/github/humblFINANCE-org/humblDATA/menv/lib/python3.11/site-packages/openbb_econdb/utils/symbol_to_indicator.json'mode='r'encoding='UTF-8'>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stoppingafter1failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=======================================================1failedin8.03s=======================================================
Desktop (please complete the following information):
OS: macOS 15
Python version: 3.11.9
Micromamba Environment
OpenBB: 4.2.2
Additional context
It seems that using json.load() leaves files hanging open when setting up a pytest. These files should be read in with a context manager.
The text was updated successfully, but these errors were encountered:
jjfantini
changed the title
[Bug]:
[Bug]: openbb_econdb/utils/helpers.pyjson.load needs to use context manager
Jun 18, 2024
Describe the bug
I am running some pytests for my
humblDATA
package. I am using a few bob calls to get financial data, and I am running into an unclosed file error:To Reproduce
Anytime I use a function that imports
obb
Screenshots
Desktop (please complete the following information):
Additional context
It seems that using
json.load()
leaves files hanging open when setting up a pytest. These files should be read in with a context manager.The text was updated successfully, but these errors were encountered: