Add some typing to tests

This commit is contained in:
Ayaz Salikhov
2022-01-18 19:13:17 +03:00
parent ee77b7831e
commit 2a1316c9ac
24 changed files with 211 additions and 141 deletions

View File

@@ -2,26 +2,28 @@
# Distributed under the terms of the Modified BSD License.
import logging
import os
from pathlib import Path
from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__)
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
THIS_DIR = Path(__file__).absolute()
def test_units(container):
def test_units(container: TrackedContainer) -> None:
"""Various units tests
Add a py file in the {image}/test/units dir and it will be automatically tested
"""
short_image_name = container.image_name[container.image_name.rfind("/") + 1 :]
host_data_dir = os.path.join(THIS_DIR, f"../{short_image_name}/test/units")
host_data_dir = THIS_DIR / f"../{short_image_name}/test/units"
LOGGER.info(f"Searching for units tests in {host_data_dir}")
cont_data_dir = "/home/jovyan/data"
if not os.path.exists(host_data_dir):
if not host_data_dir.exists():
LOGGER.info(f"Not found unit tests for image: {container.image_name}")
return
for test_file in os.listdir(host_data_dir):
for test_file in host_data_dir.iterdir():
LOGGER.info(f"Running unit test: {test_file}")
c = container.run(