diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index e88fbffab..000000000 --- a/.coveragerc +++ /dev/null @@ -1,5 +0,0 @@ -[run] -branch = True -omit = - vermouth/tests/* - vermouth/redistributed/* diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0d6d5e995..6dea77172 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -52,7 +52,7 @@ jobs: - name: Run pytest with codecoverage run: | - coverage run --source=vermouth $(which pytest) -vv vermouth --hypothesis-show-statistics + coverage run $(which pytest) -vv --hypothesis-show-statistics coverage report --omit='*/bin/pytest' - if: ${{ matrix.WITH_CODECOV }} diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 1ebf193c2..72e8c9db4 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -53,7 +53,11 @@ jobs: pip install -r requirements-tests.txt - name: Run pytest with codecoverage - run: pytest vermouth --cov=vermouth --cov-report=xml --hypothesis-show-statistics + run: | + coverage run $(which pytest) -vv --hypothesis-show-statistics + coverage report + coverage xml + - if: ${{ matrix.WITH_CODECOV }} name: Upload coverage codecov uses: codecov/codecov-action@v3 diff --git a/pyproject.toml b/pyproject.toml index 44bfde4dc..b2a592a45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,3 +4,13 @@ requires = [ "setuptools >= 30.3.0", "pbr", ] + +[tool.pytest.ini_options] +addopts = "--import-mode=importlib" +testpaths = ["vermouth/tests"] +python_files = "test_*.py" + +[tool.coverage.run] +branch = true +omit = ["vermouth/tests/*", "vermouth/redistributed/*", '*/bin/pytest'] +source_pkgs = ["vermouth"] diff --git a/vermouth/processors/attach_mass.py b/vermouth/processors/attach_mass.py index 538117d33..bd2d5adae 100644 --- a/vermouth/processors/attach_mass.py +++ b/vermouth/processors/attach_mass.py @@ -18,10 +18,13 @@ from .processor import Processor +from ..log_helpers import StyleAdapter, get_logger -# TODO: make the masses part of the forcefield -ATOM_MASSES = {'H': 1, 'C': 12, 'N': 14, 'O': 16, 'S': 32, 'P': 31, 'M': 0} +LOGGER = StyleAdapter(get_logger(__name__)) +# TODO: make the masses part of the forcefield +ATOM_MASSES = {'H': 1, 'C': 12, 'N': 14, 'O': 16, 'S': 32, 'P': 31} +DEFAULT_MASS = 30 def attach_mass(molecule, attribute='mass'): """ @@ -36,7 +39,11 @@ def attach_mass(molecule, attribute='mass'): The attribute the mass is assigned to. """ for node in molecule.nodes.values(): - node[attribute] = ATOM_MASSES[node['element']] + element = node['element'] + if element not in ATOM_MASSES: + LOGGER.info("Cannot find a mass for element {}. We assume it's some" + " metal, and will set its mass to {} amu.", element, DEFAULT_MASS) + node[attribute] = ATOM_MASSES.get(node['element'], DEFAULT_MASS) class AttachMass(Processor):