File: test_naccess.py

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (39 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
''' Unit tests for the Naccess wrapper
'''

import unittest
import sys
import shutil
import tempfile

from ost.bindings import naccess
from ost import io, settings

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)
        ost_ent = io.LoadPDB('testfiles/testprotein.pdb')
        excp_raised = False
        try:
            sasa = naccess.CalculateSurfaceArea(ost_ent, 
                                                scratch_dir=na_tmp_dir)
        except:
            excp_raised = True
            raise
        self.assertEqual(excp_raised, False, msg="Naccess raised an "+
                          "exception on a path containing a '.'. This is not "+
                          "supposed to happen.")

if __name__ == "__main__":
    try:
        settings.Locate("naccess")
    except:
        print("Could not find NACCESS, could not test binding...")
        sys.exit(0)
    from ost import testutils
    testutils.RunTests()