'How to configure VS Code pytest extension to show test results in the integrated terminal (instead of the integrated output)?

When I run tests with the VS Code pytest extension, it prints the results to the integrated output, but I'd rather have them in in the integrated terminal.

enter image description here

I found this, but unfortunately the settings code snippet which might exposes what I am looking for, has dead links on the images and does not show up (couldn't find it in the corresponding github repo neither) :(

Does anyone has a clue how to change this (probably in settings.json)? Is it even possible to print the results in the integrated terminal?

Thanks in advance!



Solution 1:[1]

There isn't a way to have test runs triggered via the extension print out to the terminal. You will need to run your tests manually in the terminal to get the output there.

Solution 2:[2]

Try again with the latest update (on 1.61.0 as of writing this) — at this point in time, I am getting the output in the integrated terminal, too.

enter image description here

Solution 3:[3]

I tried to add -s to pytest.ini or setting.json and none of them worked. The only way I was able to make something decent was by creating a vscode task:

Just create a simple json Task and use this simple script to either run all the tests in a file or select the function name and run the other task to run a single pytest:

enter image description here

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "pytest-file",
      "type": "shell",
      "command": "pytest ${file} -s"
    },
    {
      "label": "pytest-test",
      "type": "shell",
      "command": "pytest ${file} -k ${selectedText} -s"
    },
  ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brett Cannon
Solution 2 pavol.kutaj
Solution 3 Yar