diff -r ddc46e93ccc4 -r e7fd342f8bfc eric7/Unittest/Interfaces/UTFrameworkRegistry.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eric7/Unittest/Interfaces/UTFrameworkRegistry.py Thu May 12 08:59:13 2022 +0200 @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a simple registry containing the available test framework +interfaces. +""" + +import copy + + +class UTFrameworkRegistry(): + """ + Class implementing a simple registry of test framework interfaces. + + The test executor for a framework is responsible for running the tests, + receiving the results and preparing them for display. It must implement + the interface of UTExecutorBase. + + Frameworks must first be registered using '.register()'. This registry + can then create the assoicated test executor when '.createExecutor()' is + called. + """ + def __init__(self): + """ + Constructor + """ + self.__frameworks = {} + + def register(self, executorClass): + """ + Public method to register a test framework executor. + + @param executorClass class implementing the test framework executor + @type UTExecutorBase + """ + self.__frameworks[executorClass.name] = executorClass + + def createExecutor(self, framework, widget, logfile=None): + """ + Public method to create a test framework executor. + + Note: The executor classes have to be registered first. + + @param framework name of the test framework + @type str + @param widget reference to the unit test widget + @type UnittestWidget + @param logfile file name to log test results to (defaults to None) + @type str (optional) + @return test framework executor object + """ + cls = self.__frameworks[framework] + return cls(widget, logfile=logfile) + + def getFrameworks(self): + """ + Public method to get a copy of the registered frameworks. + + @return copy of the registered frameworks + @rtype dict + """ + return copy.copy(self.__frameworks)