Skip to content
Snippets Groups Projects
Commit 2b7ab33b authored by Bienchen's avatar Bienchen
Browse files

Making naccess a bit more secure with dots

parent cac56d83
No related branches found
No related tags found
No related merge requests found
......@@ -60,9 +60,9 @@ def _SetupFiles(entity, selection, scratch_dir, max_number_of_atoms):
raise RuntimeError, "Could not create view for selection (%s)"%(selection)
# write entity to tmp file
tmp_file_name=os.path.join(tmp_dir_name,"entity.pdb")
tmp_file_name = "entity.pdb"
tmp_file_base = os.path.join(tmp_dir_name,"entity")
io.SavePDB(entity_view, tmp_file_name)
io.SavePDB(entity_view, os.path.join(tmp_dir_name, tmp_file_name))
return (tmp_dir_name, tmp_file_name, tmp_file_base)
......
......@@ -4,6 +4,7 @@ set(OST_BINDINGS_UNIT_TESTS
test_hhblits.py
test_blast.py
test_kclust.py
test_naccess.py
)
ost_unittest(MODULE bindings
......
''' Unit tests for the Naccess wrapper
'''
import unittest
import os
import sys
import shutil
import tempfile
from ost.bindings import naccess
from ost import io
class TestNaccessBindings(unittest.TestCase):
def testTempDirWithDot(self):
# naccess itself has problems with '.' in the path. So we need to test
# that it works when data is used which has a correpsonding path.
na_tmp_dir = tempfile.mkdtemp(prefix="ih.")
def cleanup():
shutil.rmtree(na_tmp_dir)
self.addCleanup(cleanup)
na_bin = os.path.join(os.getenv('EBROOTNACCESS'), 'naccess')
ost_ent = io.LoadPDB('testfiles/testprotein.pdb')
excp_raised = False
try:
sasa = naccess.CalculateSurfaceArea(ost_ent,
scratch_dir=na_tmp_dir,
naccess_exe=na_bin)
except:
excp_raised = True
raise
self.assertEquals(excp_raised, False, msg="Naccess raised an "+
"exception on a path containing a '.'. This is not "+
"supposed to happen.")
if __name__ == "__main__":
naccess_dir = os.getenv('EBROOTNACCESS')
if not naccess_dir:
print "No environment variable 'EBROOTNACCESS'. To enable the "+\
"unit test, this needs to point to your Naccess installation."
sys.exit(0)
from ost import testutils
testutils.RunTests()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment