eric7/Unittest/Interfaces/UnittestExecutor.py

branch
unittest
changeset 9059
e7fd342f8bfc
child 9062
7f27bf3b50c3
equal deleted inserted replaced
9057:ddc46e93ccc4 9059:e7fd342f8bfc
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the executor for the standard 'unittest' framework.
8 """
9
10 import contextlib
11 import json
12 import os
13
14 from PyQt6.QtCore import QProcess
15
16 from .UTExecutorBase import UTExecutorBase
17
18
19 class UnittestExecutor(UTExecutorBase):
20 """
21 Class implementing the executor for the standard 'unittest' framework.
22 """
23 module = "unittest"
24 name = "unittest"
25
26 runner = os.path.join(os.path.dirname(__file__), "UnittestRunner.py")
27
28 def getVersions(self, interpreter):
29 """
30 Public method to get the test framework version and version information
31 of its installed plugins.
32
33 @param interpreter interpreter to be used for the test
34 @type str
35 @return dictionary containing the framework name and version and the
36 list of available plugins with name and version each
37 @rtype dict
38 """
39 proc = QProcess()
40 proc.start(interpreter, [UnittestExecutor.runner, "versions"])
41 if proc.waitForFinished(3000):
42 exitCode = proc.exitCode()
43 if exitCode == 0:
44 versionsStr = self.readAllOutput(proc)
45 with contextlib.suppress(json.JSONDecodeError):
46 return json.loads(versionsStr)
47
48 return {}
49
50 def createArguments(self, config):
51 """
52 Public method to create the arguments needed to start the test process.
53
54 @param config configuration for the test execution
55 @type UTTestConfig
56 @return list of process arguments
57 @rtype list of str
58 @exception NotImplementedError this method needs to be implemented by
59 derived classes
60 """
61 raise NotImplementedError
62
63 return []

eric ide

mercurial