eric7/Testing/Interfaces/TestFrameworkRegistry.py

branch
unittest
changeset 9066
a219ade50f7c
parent 9062
7f27bf3b50c3
child 9192
a763d57e23bc
equal deleted inserted replaced
9065:39405e6eba20 9066:a219ade50f7c
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a simple registry containing the available test framework
8 interfaces.
9 """
10
11 import copy
12
13
14 class TestFrameworkRegistry():
15 """
16 Class implementing a simple registry of test framework interfaces.
17
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
20 the interface of TestExecutorBase.
21
22 Frameworks must first be registered using '.register()'. This registry
23 can then create the assoicated test executor when '.createExecutor()' is
24 called.
25 """
26 def __init__(self):
27 """
28 Constructor
29 """
30 self.__frameworks = {}
31
32 def register(self, executorClass):
33 """
34 Public method to register a test framework executor.
35
36 @param executorClass class implementing the test framework executor
37 @type TestExecutorBase
38 """
39 self.__frameworks[executorClass.name] = executorClass
40
41 def createExecutor(self, framework, widget):
42 """
43 Public method to create a test framework executor.
44
45 Note: The executor classes have to be registered first.
46
47 @param framework name of the test framework
48 @type str
49 @param widget reference to the unit test widget
50 @type TestingWidget
51 @return test framework executor object
52 @rtype TestExecutorBase
53 """
54 cls = self.__frameworks[framework]
55 return cls(widget)
56
57 def getFrameworks(self):
58 """
59 Public method to get a copy of the registered frameworks.
60
61 @return copy of the registered frameworks
62 @rtype dict
63 """
64 return copy.copy(self.__frameworks)

eric ide

mercurial