archive
/
catfish
Archived
1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
catfish/tests/__init__.py

31 lines
859 B
Python

from aiounittest import AsyncTestCase
from aiohttp.test_utils import unused_port
from click.testing import CliRunner
from catfish.__main__ import cli
from catfish import worker
import functools
from multiprocessing import Process
class BaseTestCase(AsyncTestCase):
def setUp(self):
worker.stop_worker()
self.cli_runner = CliRunner()
self.cli = cli
self.run_cli = functools.partial(self.cli_runner.invoke, self.cli)
def tearDown(self):
worker.stop_worker()
class BaseWorkerTestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.unused_port = unused_port()
self.router_process = Process(target=worker.run, args=(self.unused_port,), daemon=True)
self.router_process.start()
def tearDown(self):
self.router_process.terminate()
super().tearDown()