33import os
44import shutil
55import sys
6+ import tempfile
67import unittest
78
89from pymatgen .core import Element , Structure
@@ -34,6 +35,10 @@ def setUp(self):
3435 ]
3536 with open (param_file ) as fp :
3637 jdata = json .load (fp )
38+ self .input_dir = tempfile .mkdtemp ()
39+ from_poscar_path = os .path .join (self .input_dir , "nested.POSCAR" )
40+ shutil .copy2 ("POSCAR" , from_poscar_path )
41+ jdata ["from_poscar_path" ] = from_poscar_path
3742 out_dir = out_dir_name (jdata )
3843 jdata ["out_dir" ] = out_dir
3944 self .root_dir = out_dir
@@ -47,13 +52,16 @@ def setUp(self):
4752
4853 def tearDown (self ):
4954 shutil .rmtree (self .root_dir )
55+ shutil .rmtree (self .input_dir )
5056
5157 def test (self ):
52- surfs = glob .glob ("POSCAR.01x01x01/ 01.scale_pert/ surf*" )
58+ surfs = glob .glob (os . path . join ( self . root_dir , " 01.scale_pert" , " surf*") )
5359 surfs = [ii .split ("/" )[- 1 ] for ii in surfs ]
5460 surfs .sort ()
5561 self .assertEqual (surfs , self .surfs )
56- poscars = glob .glob ("POSCAR.01x01x01/00.place_ele/surf*/sys*/POSCAR" )
62+ poscars = glob .glob (
63+ os .path .join (self .root_dir , "00.place_ele" , "surf*" , "sys*" , "POSCAR" )
64+ )
5765 for poscar in poscars :
5866 surf = poscar .split ("/" )[- 3 ]
5967 st1 = Structure .from_file (surf + ".POSCAR" )
@@ -63,7 +71,14 @@ def test(self):
6371
6472 for surf in self .surfs :
6573 elongs = glob .glob (
66- "POSCAR.01x01x01/01.scale_pert/" + surf + "/sys-*/scale-1.000/el*"
74+ os .path .join (
75+ self .root_dir ,
76+ "01.scale_pert" ,
77+ surf ,
78+ "sys-*" ,
79+ "scale-1.000" ,
80+ "el*" ,
81+ )
6782 )
6883 elongs = [ii .split ("/" )[- 1 ] for ii in elongs ]
6984 elongs .sort ()
0 commit comments