|
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 'pytest' framework. |
|
8 """ |
|
9 |
|
10 import contextlib |
|
11 import json |
|
12 import os |
|
13 |
|
14 from PyQt6.QtCore import QProcess |
|
15 |
|
16 from .TestExecutorBase import TestExecutorBase |
|
17 |
|
18 |
|
19 # TODO: implement 'pytest' support in PytestExecutor |
|
20 class PytestExecutor(TestExecutorBase): |
|
21 """ |
|
22 Class implementing the executor for the 'pytest' framework. |
|
23 """ |
|
24 module = "pytest" |
|
25 name = "pytest" |
|
26 |
|
27 runner = os.path.join(os.path.dirname(__file__), "PytestRunner.py") |
|
28 |
|
29 def getVersions(self, interpreter): |
|
30 """ |
|
31 Public method to get the test framework version and version information |
|
32 of its installed plugins. |
|
33 |
|
34 @param interpreter interpreter to be used for the test |
|
35 @type str |
|
36 @return dictionary containing the framework name and version and the |
|
37 list of available plugins with name and version each |
|
38 @rtype dict |
|
39 """ |
|
40 proc = QProcess() |
|
41 proc.start(interpreter, [PytestExecutor.runner, "versions"]) |
|
42 if proc.waitForFinished(3000): |
|
43 exitCode = proc.exitCode() |
|
44 if exitCode == 0: |
|
45 outputLines = self.readAllOutput(proc).splitlines() |
|
46 for line in outputLines: |
|
47 if line.startswith("{") and line.endswith("}"): |
|
48 with contextlib.suppress(json.JSONDecodeError): |
|
49 return json.loads(line) |
|
50 |
|
51 return {} |