diff --git a/piker/config.py b/piker/config.py index e2c63ea4..ab8e0dd7 100644 --- a/piker/config.py +++ b/piker/config.py @@ -427,7 +427,7 @@ def load_accounts( ) -> bidict[str, str | None]: - conf, path = load() + conf, path = load(touch_if_dne=True) accounts = bidict() for provider_name, section in conf.items(): accounts_section = section.get('accounts') diff --git a/tests/conftest.py b/tests/conftest.py index 366d5d95..6f170615 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -174,12 +174,13 @@ def tmpconfdir( ) assert path.is_file(), 'WTH.. `brokers.toml` not created!?' - return tmpconfdir + yield tmpconfdir # NOTE: the `tmp_dir` fixture will wipe any files older then 3 test # sessions by default: # https://docs.pytest.org/en/6.2.x/tmpdir.html#the-default-base-temporary-directory # BUT, if we wanted to always wipe conf dir and all contained files, + # from shutil import rmtree # rmtree(str(tmp_path)) diff --git a/tests/test_configs.py b/tests/test_configs.py new file mode 100644 index 00000000..a1fee2cd --- /dev/null +++ b/tests/test_configs.py @@ -0,0 +1,15 @@ +''' + testing the creation of brokers.toml if it doesn't exist, + FileNotFoundError was found when trying to run piker chart on windows. + +''' +from pathlib import Path + +from piker import config + + +def test_brokers_created_from_template_on_load_accounts(): + # load account names from ``brokers.toml`` + accounts_def = config.load_accounts( + providers=['binance'], + ) \ No newline at end of file