Add hacky cleanup solution for _testng data

paper_trade_improvements_rebase
algorandpa 2023-02-14 17:06:48 -05:00 committed by jaredgoldman
parent 66c568c7bc
commit 51ce71c969
2 changed files with 18 additions and 8 deletions

View File

@ -33,7 +33,6 @@ from .log import get_logger
log = get_logger('broker-config')
# taken from ``click`` since apparently they have some
# super weirdness with sigint and sudo..no clue
def get_app_dir(app_name, roaming=True, force_posix=False):
@ -73,7 +72,11 @@ def get_app_dir(app_name, roaming=True, force_posix=False):
"""
def _posixify(name):
return "-".join(name.split()).lower()
# TODO: This is a hacky way to a) determine we're testing
# and b) creating a test dir. We should aim to set a variable
# within the tractor runtimes and store testing config data
# outside of the users filesystem
if "pytest" in sys.modules:
app_name += '/_testing'

View File

@ -2,6 +2,9 @@ import trio
import pytest
import tractor
import math
import os
from shutil import rmtree
from piker.config import get_app_dir
from piker.log import get_logger
from piker.clearing._messages import (
Order
@ -11,30 +14,34 @@ from typing import (
AsyncContextManager,
Literal,
)
from functools import partial
from piker.pp import (
open_trade_ledger,
open_pps,
)
from piker.clearing import (
open_ems,
)
from piker.clearing._client import (
OrderBook,
)
from piker.clearing._messages import (
BrokerdPosition
)
from exceptiongroup import BaseExceptionGroup
log = get_logger(__name__)
@pytest.fixture
def paper_cleanup():
yield
app_dir = get_app_dir('piker')
rmtree(app_dir)
assert not os.path.isfile(app_dir)
def test_paper_trade(
open_test_pikerd: AsyncContextManager
open_test_pikerd: AsyncContextManager,
paper_cleanup: None
):
test_exec_mode='live'