diff -r ddc46e93ccc4 -r e7fd342f8bfc eric7/Unittest/Interfaces/PytestExecutor.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eric7/Unittest/Interfaces/PytestExecutor.py Thu May 12 08:59:13 2022 +0200 @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing the executor for the 'pytest' framework. +""" + +import contextlib +import json +import os + +from PyQt6.QtCore import QProcess + +from .UTExecutorBase import UTExecutorBase + + +class PytestExecutor(UTExecutorBase): + """ + Class implementing the executor for the 'pytest' framework. + """ + module = "pytest" + name = "pytest" + + runner = os.path.join(os.path.dirname(__file__), "PytestRunner.py") + + def getVersions(self, interpreter): + """ + Public method to get the test framework version and version information + of its installed plugins. + + @param interpreter interpreter to be used for the test + @type str + @return dictionary containing the framework name and version and the + list of available plugins with name and version each + @rtype dict + """ + proc = QProcess() + proc.start(interpreter, [PytestExecutor.runner, "versions"]) + if proc.waitForFinished(3000): + exitCode = proc.exitCode() + if exitCode == 0: + outputLines = self.readAllOutput(proc).splitlines() + for line in outputLines: + if line.startswith("{") and line.endswith("}"): + with contextlib.suppress(json.JSONDecodeError): + return json.loads(line) + + return {}