|
1 | 1 | # This code is part of OpenFE and is licensed under the MIT license.
|
2 | 2 | # For details, see https://github.com/OpenFreeEnergy/openfe
|
| 3 | +import os |
3 | 4 | import importlib
|
4 | 5 | import pytest
|
5 | 6 | from importlib import resources
|
|
11 | 12 | from gufe import SmallMoleculeComponent, LigandAtomMapping
|
12 | 13 |
|
13 | 14 |
|
| 15 | +# allow for optional slow tests |
| 16 | +# See: https://docs.pytest.org/en/latest/example/simple.html |
| 17 | +def pytest_addoption(parser): |
| 18 | + parser.addoption( |
| 19 | + "--runslow", action="store_true", default=False, help="run slow tests" |
| 20 | + ) |
| 21 | + |
| 22 | + |
| 23 | +def pytest_configure(config): |
| 24 | + config.addinivalue_line("markers", "slow: mark test as slow to run") |
| 25 | + |
| 26 | + |
| 27 | +def pytest_collection_modifyitems(config, items): |
| 28 | + if (config.getoption("--runslow") or |
| 29 | + os.environ['OFE_SLOW_TESTS'].lower() == 'true'): |
| 30 | + # --runslow given in cli or OFE_SLOW_TESTS set to True in env vars |
| 31 | + # do not skip slow tests |
| 32 | + return |
| 33 | + msg = ("need --runslow pytest cli option or the environment variable " |
| 34 | + "`OFE_SLOW_TESTS` set to `True` to run") |
| 35 | + skip_slow = pytest.mark.skip(reason=msg) |
| 36 | + for item in items: |
| 37 | + if "slow" in item.keywords: |
| 38 | + item.add_marker(skip_slow) |
| 39 | + |
| 40 | + |
14 | 41 | def mol_from_smiles(smiles: str) -> Chem.Mol:
|
15 | 42 | m = Chem.MolFromSmiles(smiles)
|
16 | 43 | AllChem.Compute2DCoords(m)
|
17 | 44 |
|
18 | 45 | return m
|
19 | 46 |
|
| 47 | + |
20 | 48 | @pytest.fixture(scope='session')
|
21 | 49 | def ethane():
|
22 | 50 | return SmallMoleculeComponent(mol_from_smiles('CC'))
|
|
0 commit comments