Module EDFactoryPluginTest
|
|
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 __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
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
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
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