src/eric7/Testing/Interfaces/PytestExecutor.py

branch
eric7
changeset 9311
8e588f403fd9
parent 9221
bf71ee032bb4
child 9313
6bac6775abb2
diff -r 8ab45a4a6d96 -r 8e588f403fd9 src/eric7/Testing/Interfaces/PytestExecutor.py
--- a/src/eric7/Testing/Interfaces/PytestExecutor.py	Sun Sep 04 16:11:32 2022 +0200
+++ b/src/eric7/Testing/Interfaces/PytestExecutor.py	Mon Sep 05 18:08:43 2022 +0200
@@ -87,6 +87,44 @@
 
         return False
 
+    def supportsMarkers(self, interpreter):
+        """
+        Public method to indicate the support for test filtering using markers and/or
+        marker expressions.
+
+        @param interpreter interpreter to be used for the test
+        @type str
+        @return flag indicating support of markers
+        @rtype bool
+        """
+        return True
+
+    def getMarkers(self, interpreter, workdir):
+        """
+        Public method to get the list of defined markers.
+
+        @param interpreter interpreter to be used for the test
+        @type str
+        @param workdir name of the working directory
+        @type str
+        @return dictionary containing the marker as key and the associated description
+            as value
+        @rtype dict
+        """
+        proc = QProcess()
+        proc.setWorkingDirectory(workdir)
+        proc.start(interpreter, [PytestExecutor.runner, "markers"])
+        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 {}
+
     def createArguments(self, config):
         """
         Public method to create the arguments needed to start the test process.
@@ -122,6 +160,10 @@
             if not config.eraseCoverage:
                 args.append("--cov-append")
 
+        if config.testMarkerExpression:
+            args.append("-m")
+            args.append(config.testMarkerExpression)
+
         if config.testFilename:
             if config.testName:
                 args.append(

eric ide

mercurial