1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
import pytest
from ase import Atoms
@pytest.fixture
def atoms_co():
"""Simple atoms object for testing with a single CO molecule"""
d = 1.14
atoms = Atoms('CO', positions=[(0, 0, 0), (0, 0, d)], pbc=True)
atoms.center(vacuum=5)
return atoms
@pytest.fixture
def atoms_2co():
"""Simple atoms object for testing with 2x CO molecules"""
d = 1.14
atoms = Atoms('CO', positions=[(0, 0, 0), (0, 0, d)], pbc=True)
atoms.extend(Atoms('CO', positions=[(0, 2, 0), (0, 2, d)]))
atoms.center(vacuum=5.)
return atoms
@pytest.fixture
def mock_vasp_calculate(mocker):
"""Fixture which mocks the VASP run method, so a calculation cannot run.
Acts as a safeguard for tests which want to test VASP,
but avoid accidentally launching a calculation"""
def _mock_run(self, command=None, out=None, directory=None):
assert False, 'Test attempted to launch a calculation'
# Patch the calculate and run methods, so we're certain
# calculations aren't accidentally launched
mocker.patch('ase.calculators.vasp.Vasp._run', _mock_run)
yield
|