9 """ |
9 """ |
10 |
10 |
11 import copy |
11 import copy |
12 |
12 |
13 |
13 |
14 class TestFrameworkRegistry(): |
14 class TestFrameworkRegistry: |
15 """ |
15 """ |
16 Class implementing a simple registry of test framework interfaces. |
16 Class implementing a simple registry of test framework interfaces. |
17 |
17 |
18 The test executor for a framework is responsible for running the tests, |
18 The test executor for a framework is responsible for running the tests, |
19 receiving the results and preparing them for display. It must implement |
19 receiving the results and preparing them for display. It must implement |
20 the interface of TestExecutorBase. |
20 the interface of TestExecutorBase. |
21 |
21 |
22 Frameworks must first be registered using '.register()'. This registry |
22 Frameworks must first be registered using '.register()'. This registry |
23 can then create the assoicated test executor when '.createExecutor()' is |
23 can then create the assoicated test executor when '.createExecutor()' is |
24 called. |
24 called. |
25 """ |
25 """ |
|
26 |
26 def __init__(self): |
27 def __init__(self): |
27 """ |
28 """ |
28 Constructor |
29 Constructor |
29 """ |
30 """ |
30 self.__frameworks = {} |
31 self.__frameworks = {} |
31 |
32 |
32 def register(self, executorClass): |
33 def register(self, executorClass): |
33 """ |
34 """ |
34 Public method to register a test framework executor. |
35 Public method to register a test framework executor. |
35 |
36 |
36 @param executorClass class implementing the test framework executor |
37 @param executorClass class implementing the test framework executor |
37 @type TestExecutorBase |
38 @type TestExecutorBase |
38 """ |
39 """ |
39 self.__frameworks[executorClass.name] = executorClass |
40 self.__frameworks[executorClass.name] = executorClass |
40 |
41 |
41 def createExecutor(self, framework, widget): |
42 def createExecutor(self, framework, widget): |
42 """ |
43 """ |
43 Public method to create a test framework executor. |
44 Public method to create a test framework executor. |
44 |
45 |
45 Note: The executor classes have to be registered first. |
46 Note: The executor classes have to be registered first. |
46 |
47 |
47 @param framework name of the test framework |
48 @param framework name of the test framework |
48 @type str |
49 @type str |
49 @param widget reference to the unit test widget |
50 @param widget reference to the unit test widget |
50 @type TestingWidget |
51 @type TestingWidget |
51 @return test framework executor object |
52 @return test framework executor object |
52 @rtype TestExecutorBase |
53 @rtype TestExecutorBase |
53 """ |
54 """ |
54 cls = self.__frameworks[framework] |
55 cls = self.__frameworks[framework] |
55 return cls(widget) |
56 return cls(widget) |
56 |
57 |
57 def getFrameworks(self): |
58 def getFrameworks(self): |
58 """ |
59 """ |
59 Public method to get a copy of the registered frameworks. |
60 Public method to get a copy of the registered frameworks. |
60 |
61 |
61 @return copy of the registered frameworks |
62 @return copy of the registered frameworks |
62 @rtype dict |
63 @rtype dict |
63 """ |
64 """ |
64 return copy.copy(self.__frameworks) |
65 return copy.copy(self.__frameworks) |