Repository navigation
Debugging tests using pytest shows"TypeError: message must be set" message #14067
Copy link
Copy link
Closed
Labels
area-debuggingarea-testingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugimportantIssue identified as high-priorityIssue identified as high-priority
Description
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.languageServersetting: 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-debuggingarea-testingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugimportantIssue identified as high-priorityIssue identified as high-priority
Activity
lazarillo commentedon Sep 24, 2020
I had the same error:
I did nothing else except try to run a particular unit test within a test file via the test debugger.
Details:
kimadeline commentedon Sep 24, 2020
Thank you for reaching out Chad Bailey (@ChadBailey) and Mike Williamson (@lazarillo)! Can you reproduce this issue with multiple versions of pytest, or is it happening only when using 6.0.2?
As a side note, if other users come forward and leave a comment demonstrating they are seeing/reproducing the problem, we will raise this issue's priority.
Thanks!
seanwsmithm3 commentedon Sep 24, 2020
I am having the exact same problem using:
[04:47 PM] >pytest --version
pytest 6.0.2
[04:47 PM] >python --version
Python 3.6.9
It runs my tests and then errors after pytest completes....
========================= 4 passed, 3 xfailed in 0.32s =========================
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/ssmith/work/repos/ci-tools, configfile: tests/pytest.ini
plugins: xdist-2.1.0, metadata-1.10.0, forked-1.3.0, html-2.1.1
collected 7 items
tests/test_base_executor.py ....xxx [100%]
-------------- generated xml file: /tmp/tmp-2792E648AgEDEUge.xml ---------------
========================= 4 passed, 3 xfailed in 0.33s =========================
Error: TypeError: message must be set
[-]Error: TypeError: message must be set[/-][+]Running test using pytest shows"TypeError: message must be set" message[/+]kimadeline commentedon Sep 24, 2020
Interestingly, I could reproduce the issue if I pick
Debug All Tests, then after that any debug command will show the error message (Debug Test Methodor aDebug Testcode lens). I cannot repro the issue when I only run the tests (via theRun All Testscommand or aRun Testcode lens), or when I run tests after usingDebug All Tests.seanwsmithm3 and Mike Williamson (@lazarillo) do you have a sample repo I could use to try and replicate your issue when running the test?
For everyone: What is the output of running in the terminal the equivalent to the command ran by the extension:
path/to/python -m pytest --override-ini junit_family=xunit1 --rootdir path/to/workspace/folder --junit-xml=/path/to/a/random/xmlfile.xml .[-]Running test using pytest shows"TypeError: message must be set" message[/-][+]Debugging tests using pytest shows"TypeError: message must be set" message[/+]int19h commentedon Sep 25, 2020
Take a look at microsoft/vscode-cmake-tools#1432, and the associated PR.
12 remaining items
chs-sapentintia commentedon Oct 20, 2020
Chad Bailey (@ChadBailey) Just wanted to add that I am seeing this bug as well, and it's affecting the outcome of my tests. Although the unit tests pass if it's in debug mode or if they are just running normally, I decided to write the output of my tests to a JSON file. The two are producing different files despite both passing the tests. I don't know if this has any implications as to what the issue could be.
Forgive the poor quality of the gif, but this should show what I'm talking about better than I can explain it:
kimadeline commentedon Oct 20, 2020
Hi chs-sapentintia, if you havne't done so yet please upvote (👍) the initial post to help us prioritize it. Thanks!
GringoDotDev commentedon Oct 23, 2020
In case it helps anyone else, I was experiencing this issue (inside an attached Docker container) and resolved it by setting
justMyCode: falseand restarting the window.cuent commentedon Oct 26, 2020
I found the same problem.
I just created a test that compares the resulting output from a file.
joelricci commentedon Oct 27, 2020
I'm seeing this in Debug Console for every test:
Despite having set
justMyCode: falsein launch.json as well as in the general config (user and workspace). Don't know if it's related but seems like an error.itewk commentedon Nov 2, 2020
for me the issue was having set in python.testing.pytestargs
after i removed all the params debuging was working
VladimirDomnich commentedon Nov 9, 2020
I am observing the same issue too.
StudyExchange commentedon Nov 9, 2020
I am observing the same issue too. And my local dev environment is not work.
briangrahamww commentedon Nov 11, 2020
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.inifile in my project root directory where I have somepytest-covsettings. I needed to override this with --no-cov as mentioned in the vscode docs here. Perhaps other settings inpytests.inicould be the culprit if adding --no-cov does not resolve the issue.singleheart commentedon Nov 18, 2020
Thanks, briangrahamww! Adding "--no-cov" removed the warning "TypeError: message must be set".
luabud commentedon 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!
luabud commentedon Jan 20, 2021
This should have been out on the December release. If you still see this problem with the newest version let us know.