From 1b346949f9e240b282ad9f0163c781bcd027b2d6 Mon Sep 17 00:00:00 2001 From: Janis Fix Date: Sat, 22 Jul 2023 14:44:38 +0200 Subject: [PATCH] Fix precommit and coverage pipeline according to folder structure change --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 +- tests/test_imports.py | 21 ++++++++++----------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8712233..3856173 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_language_version: python: python3 files: | (?x)^( - dehb| + src| tests )/.*\.py$ repos: diff --git a/pyproject.toml b/pyproject.toml index 261fe68..e598cb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ [tool.pytest.ini_options] testpaths = ["tests"] # path to the test directory minversion = "3.8" -addopts = "--cov=dehb --cov-report=lcov" # Should be package name +addopts = "--cov=src --cov-report=lcov" # Should be package name pythonpath = [ "." ] diff --git a/tests/test_imports.py b/tests/test_imports.py index 4bd1c5e..9263028 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -1,28 +1,27 @@ import importlib +import pytest + + class TestImports(): - """This class bundles all import tests for the DEHB project. - """ + """This class bundles all import tests for the DEHB project.""" def test_dehb_import(self): - """Test if DEHB can be imported properly. - """ + """Test if DEHB can be imported properly.""" try: importlib.import_module("src.dehb.optimizers.dehb") except ImportError as e: - assert False, f"Failed to import dehb: {e}" + pytest.fail(f"Failed to import dehb: {e}") def test_de_import(self): - """Test if DE can be imported properly. - """ + """Test if DE can be imported properly.""" try: importlib.import_module("src.dehb.optimizers.de") except ImportError as e: - assert False, f"Failed to import de: {e}" + pytest.fail(f"Failed to import de: {e}") def test_utils_import(self): - """Test if BracketManager can be imported properly. - """ + """Test if BracketManager can be imported properly.""" try: importlib.import_module("src.dehb.utils") except ImportError as e: - assert False, f"Failed to import dehb: {e}" \ No newline at end of file + pytest.fail(f"Failed to import utils: {e}") \ No newline at end of file