-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from loriab/qcngtestsm
add multilevel testing from qcengine
- Loading branch information
Showing
12 changed files
with
802 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[pytest] | ||
minversion = 7.0 | ||
addopts = --import-mode=importlib | ||
|
||
# locations from which test helper fls can be imported | ||
pythonpath = | ||
tests/ | ||
qcmanybody/models | ||
|
||
# test fl locations rel to this fl to use if paths not specified | ||
testpaths = | ||
tests/ | ||
qcmanybody/models | ||
|
||
markers = | ||
addon: "tests require external non-required software" | ||
|
||
cfour: "tests using CFOUR software; skip if unavailable" | ||
gamess: "tests using GAMESS software; skip if unavailable" | ||
nwchem: "tests using classic NWChem software; skip if unavailable" | ||
psi4: "tests using Psi4 software; skip if unavailable" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from typing import List | ||
|
||
import pytest | ||
|
||
from qcelemental.util import parse_version, which, which_import | ||
from qcengine.testing import _programs as _programs_qcng | ||
|
||
|
||
__all__ = [ | ||
"using", | ||
"uusing", | ||
] | ||
|
||
|
||
def is_qcfractal_new_enough(version_feature_introduced): | ||
if not which_import('qcfractal', return_bool=True): | ||
return False | ||
import qcfractal | ||
return parse_version(qcfractal.__version__) >= parse_version(version_feature_introduced) | ||
|
||
|
||
# Figure out what is imported | ||
# * anything _not_ in QCEngine goes here | ||
_programs = { | ||
"vasp": False, | ||
} | ||
|
||
|
||
def has_program(name): | ||
# any aliases or merged names go here | ||
if name in _programs: | ||
return _programs[name] | ||
elif name in _programs_qcng: | ||
return _programs_qcng[name] | ||
else: | ||
raise KeyError(f"Program {name} not registered with QCManyBody testing.") | ||
|
||
|
||
_using_cache = {} | ||
|
||
|
||
def _using(program: str) -> None: | ||
if program not in _using_cache: | ||
import_message = f"Not detecting module {program}. Install package if necessary to enable tests." | ||
skip = pytest.mark.skipif(has_program(program) is False, reason=import_message) | ||
general = pytest.mark.addon | ||
particular = getattr(pytest.mark, program) | ||
|
||
all_marks = (skip, general, particular) | ||
_using_cache[program] = [_compose_decos(all_marks), all_marks] | ||
|
||
|
||
def _compose_decos(decos): | ||
# thanks, https://stackoverflow.com/a/45517876 | ||
def composition(func): | ||
for deco in reversed(decos): | ||
func = deco(func) | ||
return func | ||
return composition | ||
|
||
|
||
def uusing(program: str): | ||
"""Apply 3 marks: skipif program not detected, label "addon", and label program. | ||
This is the decorator form for whole test functions: `@mark\n@mark`. | ||
""" | ||
_using(program) | ||
return _using_cache[program][0] | ||
|
||
|
||
def using(program: str) -> List: | ||
"""Apply 3 marks: skipif program not detected, label "addon", and label program. | ||
This is the inline form for parameterizations: `marks=[]`. | ||
In combo, do `marks=[*using(), pytest.mark.quick]` | ||
""" | ||
_using(program) | ||
return _using_cache[program][1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.