You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use unittest.main() then that can try to execute tests when the unittest loader loads this. So this should work better if you protect it like this. This is the recommended way of protecting code from running on import.
I should have been doing if __name__ == '__main__': anyway.
That fixed the problem.
I think it would be a good idea to make the error more explicit (i.e. to try to detect the running of the tests, and output a message to the user, saying to use if __name__ == '__main__').
Environment data
python.languageServer
setting: PylanceExpected behaviour
When you run the tests from the Testing side bar in the extension, tests run properly when you have
unittest.main()
in a file.Actual behaviour
(with nothing in Output > Python).
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
add.py
andtest.py
add.py
put:tests.py
put:unitest.main()
to the bottom oftest.py
.test.py
withpython test.py
: tests work normally ✅Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)The text was updated successfully, but these errors were encountered: