master > master: code py - unit tests aktualisiert
This commit is contained in:
@@ -5,21 +5,42 @@
|
||||
# IMPORTS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
from unittest import TestCase;
|
||||
from pytest import fixture;
|
||||
from src.thirdparty.run import *;
|
||||
from src.thirdparty.types import *;
|
||||
from tests.thirdparty.unit import *;
|
||||
from src.core.log import log_dev;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# CONSTANTS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
LOOP: Optional[AbstractEventLoop] = None;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# FIXTURES
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@fixture(scope='module')
|
||||
def test():
|
||||
@fixture(scope='module', autouse=True)
|
||||
def test() -> TestCase:
|
||||
return TestCase();
|
||||
|
||||
@fixture(scope='module')
|
||||
def debug():
|
||||
def log(*lines: str):
|
||||
with open('logs/debug.log', 'a') as fp:
|
||||
for line in lines:
|
||||
print(line, end='\n', file=fp);
|
||||
return log;
|
||||
@fixture(scope='module', autouse=True)
|
||||
def debug() -> Callable[..., None]:
|
||||
'''
|
||||
Fixture for development purposes only.
|
||||
Logs to file 'logs/debug.log'.
|
||||
'''
|
||||
return log_dev;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# FIXTURES for async
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# NOTE: !!! Must be called 'event_loop' !!!
|
||||
@fixture(scope='session', autouse=True)
|
||||
def event_loop() -> AbstractEventLoop:
|
||||
global LOOP;
|
||||
if LOOP is None or LOOP.is_closed():
|
||||
LOOP = asyncio_new_event_loop();
|
||||
asyncio_set_event_loop(loop=LOOP);
|
||||
return LOOP;
|
||||
|
||||
Reference in New Issue
Block a user