question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:51
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
kimadelinecommented, Oct 20, 2020

Hi @chs-sapentintia, if you havne’t done so yet please upvote (👍) the initial post to help us prioritize it. Thanks!

2reactions
luabudcommented, Dec 2, 2020

This should be fixed in the insiders version of the Python extension (View > Command Palette… and run “Python: Switch to Insiders Weekly Channel” command). Please do try it out, we will release this fix soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

message must be set" when clicking debug test in VS Code ...
However, if I click the Debug Test link then I get an output message saying Error: TypeError: message must be set .
Read more >
How to handle test failures — pytest documentation
This will invoke the Python debugger at the start of every test. Setting breakpoints¶. To set a breakpoint in your code use the...
Read more >
Testing Python in Visual Studio Code
Debug tests that were executed in the most recent test run. Run all discovered tests.
Read more >
Debugging Your Unit Test Suite in Python | Capital One
And if you're using pytest to run your tests, it has a handy ... which hits an error with a confusing message, perhaps...
Read more >
Run/Debug Configuration: pytest | IntelliJ IDEA Documentation
You can specify which data sample of the parametrized test should be executed. For example, set 2-2 in this field for the sample...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found