Skip to content

Commit

Permalink
use monkeypatch to set KIM_PROPERTY_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-nikiforov-umn committed Dec 10, 2024
1 parent d001e5c commit 2528209
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
run: |
export PATH=$PATH:$PWD/aflow.3.2.14
cd tests
export KIM_PROPERTY_PATH=$PWD/mock-test-drivers-dir/*/local-props:$PWD/mock-test-drivers-dir/*/local_props
pytest
- name: Run example
Expand Down
10 changes: 5 additions & 5 deletions tests/test_KIMTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from kim_tools.test_driver import KIMTestDriver
from ase.atoms import Atoms
from ase.calculators.lj import LennardJones
import os

class TestTestDriver(KIMTestDriver):
def _calculate(self,property_name):
Expand All @@ -18,7 +19,7 @@ def _calculate(self,property_name):
self._add_key_to_current_property_instance("species", self.atoms.get_chemical_symbols()[0])
self._add_key_to_current_property_instance("mass", self.atoms.get_masses()[0], "amu", {'source-std-uncert-value':1})

def test_kimtest():
def test_kimtest(monkeypatch):
atoms = Atoms(['Ar'], [[0, 0, 0]], cell=[[1, 0, 0], [0, 2, 0], [0, 0, 2]])
test = TestTestDriver(LennardJones())
testing_property_names = [
Expand All @@ -30,13 +31,12 @@ def test_kimtest():
'atomic-mass3', # found in $PWD/mock-test-drivers-dir/mock-td/local_props. For testing how KDP will set these.
# test this using `export KIM_PROPERTY_PATH=$PWD/mock-test-drivers-dir/*/local-props:$PWD/mock-test-drivers-dir/*/local_props`
]

monkeypatch.setenv("KIM_PROPERTY_PATH", os.path.join(os.getcwd(),'mock-test-drivers-dir/*/local-props')+':'+os.path.join(os.getcwd(),'mock-test-drivers-dir/*/local_props'))

for prop_name in testing_property_names:
test(atoms,property_name=prop_name)

assert len(test.property_instances) == 6
test.write_property_instances_to_file()


if __name__ == '__main__':
test_kimtest()

0 comments on commit 2528209

Please sign in to comment.