1
"""
2
Decorators and wrappers for testing.
3
"""
4

5 26
import pkgutil
6 26
import shutil
7

8 26
import pytest
9

10

11 26
def _plugin_import(plug):
12 26
    plug_spec = pkgutil.find_loader(plug)
13 26
    if plug_spec is None:
14 0
        return False
15
    else:
16 26
        return True
17

18

19 26
def _find_executable(exe):
20 26
    if shutil.which(exe) is not None:
21 26
        return True
22
    else:
23 26
        return False
24

25

26 26
_import_message = (
27
    "Cannot import module {}. Install package if necessary and add to PYTHONPATH"
28
)
29 26
_exe_message = "Cannot detect executable {}. Install package if necessary."
30

31 26
using_openmm = pytest.mark.skipif(
32
    _plugin_import("simtk.openmm") is False, reason=_import_message.format("OpenMM")
33
)
34 26
using_sander = pytest.mark.skipif(
35
    _find_executable("sander") is False, reason=_import_message.format("sander")
36
)
37 26
using_pmemd_cuda = pytest.mark.skipif(
38
    _find_executable("pmemd.cuda") is False, reason=_import_message.format("pmemd.cuda")
39
)
40 26
using_tleap = pytest.mark.skipif(
41
    _find_executable("tleap") is False, reason=_import_message.format("tLEaP")
42
)
43

44 26
using_parmed = pytest.mark.skipif(
45
    _plugin_import("parmed") is False, reason=_import_message.format("ParmEd")
46
)

Read our documentation on viewing source code .

Loading