I have a pytest installed on virtual env in visual studio 2022. The tests run fine outside visual studio 2022, but the VS test explorer skips all tests with this error below thanks to a testlauncher.py script from vs internals, is there a way to just launch pytest against the test_xxx.py files in the test explorer? I was able to make a dotnet test
to work by adding a VSTest target in the pyproj, wondering if there’s a fix for test explorer? this is an expensive tool to no have a proper code to do just the basics
platform win32 — Python 3.12.4, pytest-8.2.2, pluggy-1.5.0
env1Scriptspython.exe "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022ENTERPRISECOMMON7IDEEXTENSIONSMICROSOFTPYTHONCOREtestlauncher.py" XXXX pytest "" 0 "" "" dummyfilename .teststest_optimization_host.py::test_bogus_endpoint --junitxml=XXXTestResultsjunitresults_e6fdf0a1-8aa1-4227-8f5c-f9bcc5b97e34.xml --rootdir=XXXX -o junit_logging=all -o junit_family=xunit1
Traceback (most recent call last):
File "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022ENTERPRISECOMMON7IDEEXTENSIONSMICROSOFTPYTHONCOREtestlauncher.py", line 189, in <module>
main()
File "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022ENTERPRISECOMMON7IDEEXTENSIONSMICROSOFTPYTHONCOREtestlauncher.py", line 30, in main
run(testRunner, coverage_file, test_file, args)
File "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022ENTERPRISECOMMON7IDEEXTENSIONSMICROSOFTPYTHONCOREtestlauncher.py", line 119, in run
patch_translate_non_printable()
File "C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022ENTERPRISECOMMON7IDEEXTENSIONSMICROSOFTPYTHONCOREtestlauncher.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'
Results for pytest not found xxxxTestResultsjunitresults_e6fdf0a1-8aa1-4227-8f5c-f9bcc5b97e34.xml
========== Test run finished: 1 Tests (0 Passed, 0 Failed, 1 Skipped) run in 176 ms ==========
========== Starting test discovery ==========
Starting pytest discovery for the XXXX project. This can take up to 60 seconds.
cd xxxx
set PYTHONPATH=XXX
env1Scriptspython.exe C:PROGRAM FILESMICROSOFT VISUAL STUDIO2022ENTERPRISECOMMON7IDEEXTENSIONSMICROSOFTPYTHONCOREPythonFilestesting_toolsrun_adapter.py discover pytest --output-file ERROR: failed to patch pytest, _pytest.compat._translate_non_printable
========== Test discovery finished: 1 Tests found in 1.5 sec ==========