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

Source Code for Module EDUtilsTest

  1  # coding: utf8 
  2  # 
  3  #    Project: The EDNA Kernel 
  4  #             http://www.edna-site.org 
  5  # 
  6  #    File: "$Id$" 
  7  # 
  8  #    Copyright (C) 2008 European Synchrotron Radiation Facility 
  9  #                       Grenoble, France 
 10  # 
 11  #    Principal authors: Marie-Francoise Incardona (incardon@esrf.fr) 
 12  #                       Olof Svensson (svensson@esrf.fr)  
 13  # 
 14  #    This program is free software: you can redistribute it and/or modify 
 15  #    it under the terms of the GNU General Public License as published by 
 16  #    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 General Public License for more details. 
 23  # 
 24  #    You should have received a copy of the GNU General Public License 
 25  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 26  # 
 27   
 28  __authors__ = [ "Olof Svensson", "Marie-Francoise Incardona", "Jérôme Kieffer" ] 
 29  __contact__ = "svensson@esrf.fr" 
 30  __license__ = "LGPLv3+" 
 31  __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" 
 32  __date__ = "20120213" 
 33   
 34  from EDUtilsPath            import EDUtilsPath 
 35  from EDUtilsFile            import EDUtilsFile 
 36  from EDFactoryPluginTest    import EDFactoryPluginTest 
 37  from EDDecorator            import deprecated 
38 39 40 -class EDUtilsTest:
41 42 __edFactoryPluginTest = None 43 44 @classmethod
45 - def getFactoryPluginTest(cls):
49 50 51 @staticmethod
52 - def readAndParseFile(_strFileName):
53 """ 54 Reads a file and parses potential existing environment variables such as: 55 - EDNA_TESTS_DATA_HOME 56 Returns the content of this file as a string 57 """ 58 return EDUtilsFile.readFileAndParseVariables(_strFileName, EDUtilsPath.getDictOfPaths())
59 60 61 @staticmethod 62 @deprecated
63 - def readFileAndParseVariable(_strFileName, _strKey, _strValue):
64 """ 65 Reads a file and parses potential existing environment variables such as: 66 Returns the content of this file as a string 67 """ 68 69 return EDUtilsFile.readFileAndParseVariables(_strFileName, {_strKey:_strValue})
70 71 72 @staticmethod 73 @deprecated
74 - def readFileAndParseVariables(_strFileName, _dictReplacements):
75 """ 76 Returns the content of this file as a string 77 """ 78 return EDUtilsFile.readFileAndParseVariables(_strFileName, _dictReplacements)
79 80 81 @staticmethod 82 @deprecated
83 - def readFile(_strFileName):
84 """ 85 Reads a file 86 Returns its content as a string 87 """ 88 return EDUtilsFile.readFile(_strFileName)
89 90 @staticmethod 91 @deprecated
92 - def writeFile(_strFileName, _strContent):
93 """ 94 Writes a string into a file 95 """ 96 EDUtilsFile.writeFile(_strFileName, _strContent)
97 98 99 100 @staticmethod 101 @deprecated
102 - def getTestsHome():
103 """ 104 Returns the tests home directory path <EDNA_HOME>/tests 105 """ 106 return EDUtilsPath.EDNA_TESTS
107 108 109 @staticmethod 110 @deprecated
111 - def getTestsDataHome():
112 """ 113 Returns the tests data directory path <EDNA_HOME>/tests/data 114 """ 115 return EDUtilsPath.EDNA_TESTDATA
116 117 118 @staticmethod 119 @deprecated
121 """ 122 Returns the tests data image directory path <EDNA_HOME>/tests/data/images or what is relevant 123 """ 124 return EDUtilsPath.EDNA_TESTIMAGES
125 126 127 @classmethod
128 - def getPluginTestDataDirectory(cls, _strPluginTestName):
129 """ 130 Given a test case name, returns the corresponding test data directory. 131 """ 132 strModuleLocation = cls.getFactoryPluginTest().getModuleLocation(_strPluginTestName) 133 strPluginTestDataDirectory = EDUtilsPath.appendListOfPaths(strModuleLocation, [ "..", "data" ]) 134 return strPluginTestDataDirectory
135 136 137 @classmethod
138 - def getConfigurationHome(cls, _strPluginTestName):
139 """ 140 Returns the configuration directory path for a given test module 141 """ 142 strModuleLocation = cls.getFactoryPluginTest().getModuleLocation(_strPluginTestName) 143 strConfigurationHome = EDUtilsPath.appendListOfPaths(strModuleLocation, [ "..", "..", "..", "..", "conf" ]) 144 return strConfigurationHome
145 146 147 @staticmethod
148 - def patchMethodName(_strText):
149 """ 150 Try to get the method name ... by first converting it to a string an processing the string ... not optimal but it works 151 152 Nota: Refactored as a static method, 20100430 JKR 153 154 @param _strText: anything that could be converted to string, here it seems to be a method or a function 155 @return: the word after the 156 @rtype: string 157 """ 158 strReturn = "None Object" 159 listWords = str(_strText).replace("<", " ").split() 160 if "method" in listWords: 161 i = listWords.index("method") 162 if i < len(listWords) - 1: 163 strReturn = listWords[i + 1] 164 return strReturn
165