Skip to content

Debugging tests using pytest shows"TypeError: message must be set" message #14067

@ChadBailey

Description

@ChadBailey

Environment data

Version: 1.49.1 (user setup)
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-16T23:27:51.792Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363
  • VS Code version: 1.4
  • Extension version (available under the Extensions sidebar): v2020.9.111407
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.5 (64 bit)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Value of the python.languageServer setting: 0.5.51.0

Full language server log

[Info  - 6:26:45 PM] Analysis cache path: C:\Users\Chad\AppData\Local\Microsoft\Python Language Server
[Info  - 6:26:45 PM] Microsoft Python Language Server version 0.5.51.0
[Info  - 6:26:45 PM] Workspace root: c:\Users\Chad\Documents\code\VSCode_Debug
[Info  - 6:26:46 PM] GetCurrentSearchPaths C:\Python38\python.exe 
[Info  - 6:26:46 PM] Interpreter search paths:
[Info  - 6:26:46 PM]     c:\python38\dlls
[Info  - 6:26:46 PM]     c:\python38\lib
[Info  - 6:26:46 PM]     c:\python38
[Info  - 6:26:46 PM]     c:\users\chad\appdata\roaming\python\python38\site-packages
[Info  - 6:26:46 PM]     c:\python38\lib\site-packages
[Info  - 6:26:46 PM] User search paths:
2020-09-23 17:26:46.6932135 [W:onnxruntime:, graph.cc:814 onnxruntime::Graph::Graph] Initializer embeddings_matrix:0_quantized appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-09-23 17:26:46.6934091 [W:onnxruntime:, graph.cc:814 onnxruntime::Graph::Graph] Initializer embeddings_matrix:0_scale appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-09-23 17:26:46.6934436 [W:onnxruntime:, graph.cc:814 onnxruntime::Graph::Graph] Initializer embeddings_matrix:0_zero_point appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-09-23 17:26:46.6934786 [W:onnxruntime:, graph.cc:814 onnxruntime::Graph::Graph] Initializer fixed_quantization_range_uint8 appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
2020-09-23 17:26:46.6935089 [W:onnxruntime:, graph.cc:814 onnxruntime::Graph::Graph] Initializer fixed_zero appears in graph inputs and will not be treated as constant value/weight. This may fail some of the graph optimizations, like const folding. Move it out of graph inputs if there is no need to override it, by either re-generating the model with latest exporter/converter or with the tool onnxruntime/tools/python/remove_initializer_from_input.py.
[Info  - 6:26:46 PM] Initializing for C:\Python38\python.exe
[Info  - 6:26:46 PM] Analysis caching mode: None.

Expected behaviour

No error

Actual behaviour

IMPORTANT: This behavior is intermittent and I'm unable to reliably reproduce it, but it does happen frequent enough that it should come up in testing.

Receiving error Error: TypeError: message must be set in Python Test Log when debugging tests (pytest) with accompanying error toast (see image)
image

Also occasionally receiving error:

Error: Error: Illegal value for `line`

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Create the following files

main.py

def main():
    raise Exception("Unhandled Exception")

if __name__ == "__main__":
    main()

main_test.py

from main import main

def test_main():
    main()
    assert True
  1. Discover tests
  2. Debug test (individually or all seems to have no impact)

Logs

============================= test session starts =============================
platform win32 -- Python 3.8.5, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
rootdir: c:\Users\Chad\Documents\code\VSCode_Debug
collected 2 items

test_main.py F.                                                        [100%]

================================== FAILURES ===================================
__________________________________ test_main __________________________________

    def test_main():
>       main()

test_main.py:4:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def main():
>       raise Exception("Unhandled Exception")
E       Exception: Unhandled Exception

main.py:2: Exception
- generated xml file: C:\Users\Chad\AppData\Local\Temp\tmp-1176wqdg9vDcmu6N.xml -
=========================== short test summary info ===========================
FAILED test_main.py::test_main - Exception: Unhandled Exception
========================= 1 failed, 1 passed in 6.85s =========================
Error: TypeError: message must be set

Metadata

Metadata

Assignees

Labels

area-debuggingarea-testingbugIssue identified by VS Code Team member as probable bugimportantIssue identified as high-priority

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions