Module EDFactoryPluginTest
[hide private]
[frames] | no frames]

Source Code for Module EDFactoryPluginTest

  1  # 
  2  #    Project: The EDNA Kernel 
  3  #             http://www.edna-site.org 
  4  # 
  5  #    File: "$Id$" 
  6  # 
  7  #    Copyright (C) 2008-2009 European Synchrotron Radiation Facility 
  8  #                            Grenoble, France 
  9  # 
 10  #    Principal author:    Olof Svensson (svensson@esrf.fr)  
 11  # 
 12  #    Contributing author: Marie-Francoise Incardona (incardon@esrf.fr) 
 13  # 
 14  #    This program is free software: you can redistribute it and/or modify 
 15  #    it under the terms of the GNU Lesser General Public License as published 
 16  #    by the Free Software Foundation, either version 3 of the License, or 
 17  #    (at your option) any later version. 
 18  # 
 19  #    This program is distributed in the hope that it will be useful, 
 20  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 21  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 22  #    GNU Lesser General Public License for more details. 
 23  # 
 24  #    You should have received a copy of the GNU General Public License 
 25  #    and the GNU Lesser General Public License  along with this program.   
 26  #    If not, see <http://www.gnu.org/licenses/>. 
 27  # 
 28  __authors__ = ["Marie-Francoise Incardona", "Olof Svensson" ] 
 29  __contact__ = "svensson@esrf.fr" 
 30  __license__ = "LGPLv3+" 
 31  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
 32   
 33  import os, sys 
 34   
 35  from EDFactoryPlugin import EDFactoryPlugin 
 36  from EDUtilsPath     import EDUtilsPath 
 37   
38 -class EDFactoryPluginTest(EDFactoryPlugin):
39 """ 40 This subclass of EDFactoryPlugin provides a factory for loading test cases for the EDNA 41 testing framework. The function of EDFactoryPluginTest is very similar to EDFactoryPlugin, 42 the main differences are that only files starting with "EDTest" are considered as test cases 43 to be loaded, and that the "src" and "plugin" directories are added to the python path from 44 two possible locations of the test case: 45 46 EDNA application, e.g. mxv1, or plugin collection e.g. mxExecPlugins:: 47 | 48 |-datamodel 49 |-src 50 |-tests 51 | |-data 52 | |-testsuite 53 | | |- EDTestSuiteXXX.py 54 | 55 |-plugins 56 | |-EDPlugin[name of plugin]-v1.0 57 | | |-plugins 58 | | | |-EDPlugin[name of plugin]v10.py 59 | | | |-EDPlugin[another name of plugin]v10.py 60 | | |-tests 61 | | | |-data 62 | | | |-testsuite 63 | | | | |-EDTestSuiteYYY.py 64 65 The "src" directory is searched relatively from both the EDTestSuiteXXX.py and 66 EDTestSuiteYYY.py locations, i.e. "../../src" and "../../../../src". 67 68 The "plugins" directory is searched only from the EDTestSuiteYYY.py location, 69 i.e. "../../plugins". 70 71 """ 72 73
74 - def isPlugin(self, _strFileName):
75 """ 76 For the testing framework, the plugins are test cases and test suites which 77 starts with "EDTest" and ends with ".py". 78 79 @param _strFileName: Name of the file 80 @type _strFileName: python string 81 82 @return: True or False 83 @type: boolean 84 """ 85 bValue = False 86 if (_strFileName.startswith("EDTest") and \ 87 _strFileName.endswith(".py")): 88 bValue = True 89 return bValue
90 91
92 - def appendPath(self, _strPluginTestLocation):
93 """ 94 For the tests, both the plugin directory and its corresponding "src" directory must 95 be on the python path (see the class documentation for EDFactoryPluginTest). 96 This method appends the plugin "src" directory to the system path, if it's not already present. 97 98 @param _strModuleLocation: Path to the module location 99 @type _strModuleLocation: python string 100 """ 101 EDFactoryPlugin.appendPath(self, _strPluginTestLocation) 102 103 strSrcDirectory = EDUtilsPath.appendListOfPaths(_strPluginTestLocation, [ "..", "..", "..", "..", "src" ]) 104 if os.path.exists(strSrcDirectory): 105 if (not strSrcDirectory in sys.path): 106 sys.path.append(strSrcDirectory) 107 108 strSrcDirectory = EDUtilsPath.appendListOfPaths(_strPluginTestLocation, [ "..", "..", "src" ]) 109 if os.path.exists(strSrcDirectory): 110 if (not strSrcDirectory in sys.path): 111 sys.path.append(strSrcDirectory) 112 113 strPluginDirectory = EDUtilsPath.appendListOfPaths(_strPluginTestLocation, [ "..", "..", "plugins" ]) 114 if os.path.exists(strPluginDirectory): 115 if (not strPluginDirectory in sys.path): 116 sys.path.append(strPluginDirectory)
117