mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 20:42:26 +00:00
* init * fix tables * add shortcuts * handle svgs * test * test2 * test3 * Update loggers.py * Update sdk_helpers.py * Update loggers.py * Update loggers.py * updates * updates * update * handle add text high/low for candlestick traces when updating * adding save overlay to tables * maybe fix * prints * asdf * working * working * removing prints * update * fix no figure title text * add trace labels space * download finished popup for MacOS * bump pywry * update * update table * Update plotly_helper.py * only format numbers over 10_000 on tables * Delete generate_index.py * turn off logs in generations * update tables * bump pywry, fix tables, added ichimoku ta indicator * Update backend.py * mypy * update tables * updates * juan more * tables * test * bump pywry * bump pywry * Update loggers.py * test * fixing some formatting * add update button to indicators dashboard * fix oecd dates to be full dates * prepare charts/tables for pywry update * Update poetry.lock * Update finviz_view.py * tests * tests * tests * tests * testss? * tests * Create test_call_func[call_sec-nasdaq_view.sec_filings-other_args37-called_with37].yaml * testtss please * Update loggers.py * testss * `with open(newline="\n")` * tests * tests -__- * why * Revert "`with open(newline="\n")`" This reverts commit554e0f53f4. * Revert "why" This reverts commit89f1d9b823. * Revert "tests -__-" This reverts commita9c694ae96. * Revert "tests" This reverts commit5463249498. * whelp * . * rename `streamlit.py` -> `streamlit_run.py`, bump pywry/finviz/streamlit * Update backend.py * update * Revert "update file" --------- Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com> Co-authored-by: James Maslek <jmaslek11@gmail.com>
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
""" Test helper """
|
|
__docformat__ = "numpy"
|
|
|
|
import pathlib
|
|
from typing import Callable
|
|
|
|
import yaml
|
|
|
|
|
|
def parameterize_from_file(test_namespace: str, parameter_file: str) -> Callable:
|
|
"""A test helper function returns a wrapper function that loads sets of parameters from a YAML and
|
|
attaches test scenarios as metadata
|
|
|
|
Parameters
|
|
----------
|
|
test_namespace : str
|
|
Test namespace to use within the YAML
|
|
parameter_file : str
|
|
Test scenario YAML to load
|
|
|
|
Returns
|
|
-------
|
|
Callable
|
|
Wrapper function
|
|
"""
|
|
|
|
def wrapper(function):
|
|
test_file_base_path = pathlib.Path(__file__).parent.absolute()
|
|
data_file_full_path = pathlib.Path(test_file_base_path, parameter_file)
|
|
|
|
with open(data_file_full_path, encoding="utf-8", newline="\n") as file:
|
|
parameter_data = yaml.full_load(file)
|
|
|
|
idlist = []
|
|
argnames = []
|
|
argvalues = []
|
|
|
|
for scenario in parameter_data[test_namespace]:
|
|
idlist.append(scenario)
|
|
argnames = []
|
|
tempvalues = []
|
|
for argname in parameter_data[test_namespace][scenario]:
|
|
argnames.append(argname)
|
|
tempvalues.append(parameter_data[test_namespace][scenario][argname])
|
|
argvalues.append(tempvalues)
|
|
|
|
function.test_params_names = argnames
|
|
function.test_param_values = argvalues
|
|
function.test_ids = idlist
|
|
|
|
return function
|
|
|
|
return wrapper
|
|
|
|
|
|
def pytest_generate_tests(metafunc):
|
|
"""https://docs.pytest.org/en/stable/parametrize.html#pytest-generate-tests"""
|
|
if getattr(metafunc.function, "test_params_names", None):
|
|
metafunc.parametrize(
|
|
metafunc.function.test_params_names,
|
|
metafunc.function.test_param_values,
|
|
ids=metafunc.function.test_ids,
|
|
scope="class",
|
|
)
|