Skip to content

SyntaxError: Unexpected token in JSON at position 23851 #8198

Closed
@brgirgis

Description

@brgirgis

Environment data

  • VS Code version: 1.39.2
  • Extension version (available under the Extensions sidebar): 2019.10.44104
  • OS and version: MS Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): miniconda
  • 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): N/A

Expected behaviour

Discover all unit tests correctly with no problems as long as pythonFiles/testing_tools/run_adapter.py returns the correct JSON data

Actual behaviour

While discovering, the loading machinery instantiates some dynamic libraries (DLLs) that output to the standard output. Apparently, run_adapter.py tries to capture all the output as the JSON object rather than the relevant return from pytest.

Steps to reproduce:

  1. Create a C/C++ DLL that writes to stdout on load
  2. Create a Python SWIG wrapper for that DLL
  3. Write a pytest unittest that uses the SWIG wrapper
  4. Test discovery fails

Logs

Output for Python Test Log in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python Test log)

python c:\<private path>\ms-python.python-2019.10.44104\pythonFiles\testing_tools\run_adapter.py discover pytest -- -s -n 4 <private project>
Test Discovery failed: 
SyntaxError: Unexpected token E in JSON at position 23851

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions