Skip to content

atexit registered functions that print to stdout break test discovery #6581

@joel-wright

Description

@joel-wright

When exit handlers that print to standard out are registered using the atexit module, pytest test discovery fails.

Environment data

  • VS Code version: 1.36.1
  • Extension version (available under the Extensions sidebar): 2019.6.24221
  • OS and version: Ubuntu Linux 18.04.2
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: pytest
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): Language Server

Expected behaviour

I would expect the relevant tests to be discovered.

Actual behaviour

Test discovery fails because extra text is appended to whatever output is used to store the JSON description of the discovered tests, which subsequently causes a SyntaxError when parsing.

Steps to reproduce:

Allow test discovery to run on the minimal demonstration repository here: https://github.com/joel-wright/pytest-discovery-atexit

Logs

Output for Python Test Log:

python /home/jjw/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear
Test Discovery failed: 
SyntaxError: Unexpected token I in JSON at position 436

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bugregressionBug didn't exist in a previous release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions