diff --git a/tests/conftest.py b/tests/conftest.py index e55cffbf..f7688a9d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,12 @@ import pytest +@pytest.fixture +def brokerconf(): + from piker.brokers import config + return config.load()[0] + + @pytest.fixture def us_symbols(): return ['TSLA', 'AAPL', 'CGC', 'CRON'] diff --git a/tests/test_questrade.py b/tests/test_questrade.py index 1a6a9f1f..897ba531 100644 --- a/tests/test_questrade.py +++ b/tests/test_questrade.py @@ -6,6 +6,15 @@ import time import trio from trio.testing import trio_test from piker.brokers import questrade as qt +import pytest + + +@pytest.fixture(autouse=True) +def check_qt_conf_section(brokerconf): + """Skip this module's tests if we have not quetrade API creds. + """ + if not brokerconf.has_section('questrade'): + pytest.skip("No questrade API credentials available") # stock quote @@ -66,7 +75,6 @@ _ex_contract = { } - def match_packet(symbols, quotes): """Verify target ``symbols`` match keys in ``quotes`` packet. """ @@ -158,7 +166,7 @@ async def test_option_quote_latency(tmx_symbols): for _ in range(10): # chains quote for all symbols start = time.time() - quotes = await client.option_chains(contract) + await client.option_chains(contract) took = time.time() - start print(f"Request took {took}") assert took <= expected_latency