Ensure to cleanup by passing fixture in paper_test signature

paper_trade_improvements_rebase
jaredgoldman 2023-02-24 18:05:17 -05:00
parent 884ddc2552
commit 6ccdb8cbf8
2 changed files with 5 additions and 8 deletions

View File

@ -78,7 +78,6 @@ def get_app_dir(app_name, roaming=True, force_posix=False):
# within the tractor runtimes and store testing config data # within the tractor runtimes and store testing config data
# outside of the users filesystem # outside of the users filesystem
if "pytest" in sys.modules: if "pytest" in sys.modules:
log.info("TESTING")
app_name = os.path.join(app_name, TEST_CONFIG_DIR_PATH) app_name = os.path.join(app_name, TEST_CONFIG_DIR_PATH)
# if WIN: # if WIN:

View File

@ -38,7 +38,7 @@ from piker.clearing._messages import BrokerdPosition
log = get_logger(__name__) log = get_logger(__name__)
@pytest.fixture(scope="module") @pytest.fixture(scope="session")
def delete_testing_dir(): def delete_testing_dir():
"""This fixture removes the temp directory """This fixture removes the temp directory
used for storing all config/ledger/pp data used for storing all config/ledger/pp data
@ -56,7 +56,7 @@ def get_fqsn(broker, symbol):
return (fqsn, symbol, broker) return (fqsn, symbol, broker)
def test_paper_trade(open_test_pikerd: AsyncContextManager): def test_paper_trade(open_test_pikerd: AsyncContextManager, delete_testing_dir):
oid = "" oid = ""
test_exec_mode = "live" test_exec_mode = "live"
test_account = "paper" test_account = "paper"
@ -71,7 +71,6 @@ def test_paper_trade(open_test_pikerd: AsyncContextManager):
] ]
async def _async_main( async def _async_main(
open_pikerd: AsyncContextManager,
action: Literal["buy", "sell"] | None = None, action: Literal["buy", "sell"] | None = None,
price: int = 30000, price: int = 30000,
assert_entries: bool = False, assert_entries: bool = False,
@ -87,7 +86,7 @@ def test_paper_trade(open_test_pikerd: AsyncContextManager):
# Set up piker and EMS # Set up piker and EMS
async with ( async with (
open_pikerd() as (_, _, _, services), open_test_pikerd() as (_, _, _, services),
open_ems(fqsn, mode="paper") as ( open_ems(fqsn, mode="paper") as (
book, book,
trades_stream, trades_stream,
@ -189,7 +188,6 @@ def test_paper_trade(open_test_pikerd: AsyncContextManager):
BaseExceptionGroup, BaseExceptionGroup,
partial( partial(
_async_main, _async_main,
open_pikerd=open_test_pikerd,
action="buy", action="buy",
), ),
# _assert_entries # _assert_entries
@ -197,13 +195,13 @@ def test_paper_trade(open_test_pikerd: AsyncContextManager):
_run_test_and_check( _run_test_and_check(
BaseExceptionGroup, BaseExceptionGroup,
partial(_async_main, open_pikerd=open_test_pikerd), partial(_async_main),
_assert_pps, _assert_pps,
) )
_run_test_and_check( _run_test_and_check(
BaseExceptionGroup, BaseExceptionGroup,
partial(_async_main, open_pikerd=open_test_pikerd, action="sell", price=1), partial(_async_main, action="sell", price=1),
_assert_no_pps, _assert_no_pps,
) )