source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/__init__.py @ 5291

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/__init__.py@5291
Revision 5291, 1.4 KB checked in by pjkersha, 10 years ago (diff)

Completed fixes to unit tests for move to 'unit' package.

Line 
1"""NDG Security unit test package
2
3NERC Data Grid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "14/05/09"
7__copyright__ = "(C) 2009 Science and Technology Facilities Council"
8__license__ = "BSD - see LICENSE file in top-level directory"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__revision__ = '$Id: __init__.py 4840 2009-01-19 13:59:08Z pjkersha $'
11
12import unittest
13import logging
14logging.basicConfig()
15
16import os
17from os.path import expandvars, join, dirname, abspath
18
19
20class BaseTestCase(unittest.TestCase):
21    '''Convenience base class from which other unit tests can extend.  Its
22    sets the generic data directory path'''
23    configDirEnvVarName = 'NDGSEC_TEST_CONFIG_DIR'
24   
25    def setUp(self):
26        if BaseTestCase.configDirEnvVarName not in os.environ:
27            os.environ[BaseTestCase.configDirEnvVarName] = \
28                join(abspath(dirname(dirname(__file__))), 'config')
29
30mkDataDirPath = lambda file:join(os.environ[BaseTestCase.configDirEnvVarName],
31                                 file)
32
33def _getParentDir(depth=0, path=dirname(__file__)):
34    """
35    @type path: basestring
36    @param path: directory path from which to get parent directoty, defaults
37    to dir of this module
38    @rtype: basestring
39    @return: parent directory at depth levels up from the current path
40    """
41    for i in range(depth):
42        path = dirname(path)
43    return path
44
45
Note: See TracBrowser for help on using the repository browser.