Skip to content

Commit

Permalink
fixing tests to match new file placement
Browse files Browse the repository at this point in the history
  • Loading branch information
donald e. boyce committed Dec 11, 2024
1 parent a4bf898 commit 53e1847
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion hexrd/config/findorientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ def file(self):
'find_orientations:orientation_maps:file',
default=None
)
if temp is not None:
if temp is None:
return None
else:
ptemp = Path(temp)
if ptemp.is_absolute():
mapf = ptemp
Expand Down
7 changes: 5 additions & 2 deletions tests/config/test_find_orientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"""
analysis_name: analysis
working_dir: %(tempdir)s
material:
definitions: %(existing_file)s
active: actmat
---
find_orientations:
orientation_maps:
Expand Down Expand Up @@ -326,11 +329,11 @@ def test_file(self):
self.cfgs[0].find_orientations.orientation_maps.file is None
)
self.assertEqual(
self.cfgs[1].find_orientations.orientation_maps.file,
str(self.cfgs[1].find_orientations.orientation_maps.file),
os.path.join(test_data['tempdir'], test_data['nonexistent_file'])
)
self.assertEqual(
self.cfgs[2].find_orientations.orientation_maps.file,
str(self.cfgs[2].find_orientations.orientation_maps.file),
test_data['existing_file']
)

Expand Down
12 changes: 8 additions & 4 deletions tests/config/test_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_reference_data(cls):

def test_analysis_dir(self):
self.assertEqual(
self.cfgs[0].analysis_dir,
str(self.cfgs[0].analysis_dir),
os.path.join(os.getcwd(), 'analysis')
)

Expand All @@ -56,11 +56,15 @@ def test_section_inheritance(self):
self.assertEqual(self.cfgs[2].analysis_name, 'analysis_2')

def test_working_dir(self):
self.assertEqual(self.cfgs[0].working_dir, os.getcwd())
self.assertEqual(self.cfgs[1].working_dir, test_data['existing_path'])
self.assertEqual(str(self.cfgs[0].working_dir), os.getcwd())
self.assertEqual(
str(self.cfgs[1].working_dir), test_data['existing_path']
)
self.assertRaises(IOError, getattr, self.cfgs[2], 'working_dir')
self.cfgs[7].working_dir = test_data['existing_path']
self.assertEqual(self.cfgs[7].working_dir, test_data['existing_path'])
self.assertEqual(
str(self.cfgs[7].working_dir), test_data['existing_path']
)
self.assertRaises(
IOError, setattr, self.cfgs[7], 'working_dir',
test_data['nonexistent_path']
Expand Down

0 comments on commit 53e1847

Please sign in to comment.