vscode-python: Debugging tests using pytest shows"TypeError: message must be set" message
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)
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]
- 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
- Discover tests
- 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 51
- Comments: 20 (2 by maintainers)
Hi @chs-sapentintia, if you havne’t done so yet please upvote (👍) the initial post to help us prioritize it. Thanks!
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!
I had the same issue and fixed it by adding
"--no-cov"
topython.testing.pytestargs
. For me the issue is that the debugger is using the settings in mypytest.ini
file in my project root directory where I have somepytest-cov
settings. I needed to override this with --no-cov as mentioned in the vscode docs here. Perhaps other settings inpytests.ini
could be the culprit if adding --no-cov does not resolve the issue.for me the issue was having set in python.testing.pytestargs
after i removed all the params debuging was working
That’s excellent timing @int19h, because I was doing some digging and I was reaching the same conclusion: diagnostics must have a message. In our current code the message (on line 500) can sometimes be
''
, which is not enough, as evidenced by https://github.com/microsoft/vscode-cmake-tools/pull/1433, many thanks for the link 🙂https://github.com/microsoft/vscode-python/blob/61b179b2092050709e3c373a6738abad8ce581c4/src/client/testing/common/managers/baseTestManager.ts#L498-L505
Alright everyone, no need for info anymore, the problematic area has been narrowed down 🔍
@ChadBailey (sorry for the many pings), if you have a reliable repro case for the
Error: Error: Illegal value for 'line'
that would be really helpful 🙂Thank you everyone!
Take a look at https://github.com/microsoft/vscode-cmake-tools/issues/1432, and the associated PR.