-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea56d45
commit 7e357a2
Showing
6 changed files
with
63 additions
and
15 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
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,53 @@ | ||
"""Testing if environmental variable correctly passes to process | ||
""" | ||
import pytest | ||
from vasp_interactive import VaspInteractive | ||
import tempfile | ||
from pathlib import Path | ||
import os | ||
import sys | ||
|
||
|
||
def test_command_env(): | ||
from ase.build import molecule | ||
|
||
# When testing under the github action system, it should be | ||
# `mpirun -np 1 <options> <path>/vasp_gam` | ||
default_command = os.environ["VASP_COMMAND"] | ||
|
||
"""Test if VaspInteractive correctly catches command if env changes | ||
""" | ||
atoms = molecule("H2", vacuum=5, pbc=True) | ||
with tempfile.TemporaryDirectory() as tempdir: | ||
tempdir = Path(tempdir) | ||
calc = VaspInteractive(xc="pbe", directory=tempdir) | ||
with calc: | ||
atoms.calc = calc | ||
assert calc.command is None | ||
command = calc.make_command() | ||
assert command == default_command | ||
atoms.get_potential_energy() | ||
# calc.process the shell mode, so args is a string | ||
assert calc.process.args == default_command | ||
|
||
# Harmless change | ||
new_command = default_command.replace("-np", "-n") | ||
calc.command = new_command | ||
# Should be no change | ||
assert calc.process.args == default_command | ||
|
||
with calc: | ||
atoms.rattle() | ||
atoms.get_potential_energy() | ||
print(calc.process.args) | ||
assert calc.process.args == new_command | ||
|
||
with calc: | ||
# reset the environ | ||
os.environ["VASP_COMMAND"] = "echo TEST && " + default_command | ||
atoms.rattle() | ||
calc.command = None | ||
atoms.get_potential_energy() | ||
assert calc.command is None | ||
print(calc.process.args) | ||
assert "TEST" in calc.process.args |
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