usnistgov / jarvis

JARVIS-Tools: an open-source software package for data-driven atomistic materials design. Publications: https://scholar.google.com/citations?user=3w6ej94AAAAJ https://www.youtube.com/watch?v=2-XHeC8gbeY
https://pages.nist.gov/jarvis/
Other
311 stars 125 forks source link

Ensure that the test suite can be run from the base directory #8

Closed wd15 closed 6 years ago

wd15 commented 6 years ago

Currently there are hardwired paths that depend on where the tests are executed. Replace these with paths that use the __file__ to determine the path. For example,

 def test_get_aea():
-   strt=Structure.from_file('../vasp/examples/SiOptb88/MAIN-ELASTIC-bulk@mp_149/POSCAR')
-   ar=get_area(strt)
-   assert ar==30.180025513225004
-
+    file_path = os.path.dirname(os.path.abspath(__file__))
+    poscar_path = '../vasp/examples/SiOptb88/MAIN-ELASTIC-bulk@mp_149/POSCAR'
+    full_path = os.path.join(file_path, poscar_path)
+    print('full_path:', full_path)
+    strt=Structure.from_file(full_path)
+    ar=get_area(strt)
+    assert ar==30.180025513225004
knc6 commented 6 years ago

implemented the os.path.join(os.path.dirname(file), '') to fix the problem.