Skip to content

Error executing test by pytest #7959

@kenichiice

Description

@kenichiice

Describe the bug
When running tests using pytest 8.3.1 on Visual Studio 2022, the following error occurs.

Note that this error does not occur when pytest 8.0.2 is used.

Traceback (most recent call last):
  File "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\testlauncher.py", line 189, in <module>
    main()
  File "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\testlauncher.py", line 30, in main
    run(testRunner, coverage_file, test_file, args)
  File "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\testlauncher.py", line 119, in run
    patch_translate_non_printable()
  File "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\EXTENSIONS\MICROSOFT\PYTHON\CORE\testlauncher.py", line 136, in patch_translate_non_printable
    translate_non_printable =  getattr(_pytest.compat, "_translate_non_printable")
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module '_pytest.compat' has no attribute '_translate_non_printable'

The _translate_non_printable that is causing the error seems to have been removed from the pytest code.

Steps to Reproduce

  1. Create a Python project on VS 2022 that uses pytest as the testing framework.
  2. Install the latest pytest (currently 8.3.1) in the Python environment of the Python project.
  3. Add any test code to the Python project.
  4. Run the test from VS's Test Explorer.

Expected behavior
No error should occur.

Sample Code
For example, the following test code will reproduce the error.

def test_failure():
    assert 1 == 1

Configuration information (If you are providing a diagnostics file (see below), skip this section)
VS Version: 17.10.4
PTVS version: 17.0.24064.1
Python version: 3.11

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions