forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
area-testingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug
Description
Environment data
- VS Code version: 1.60.0 (user setup) (Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff)
- Extension version (available under the Extensions sidebar): v2021.9.1191016588
- OS and version: Windows_NT x64 10.0.19042
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.7
- Type of virtual environment used N/A
- Value of the
python.languageServersetting: Pylance
Expected 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
Unittest Discovery Error [Folder Name]
Error discovering unittest tests (see Output > Python):
(with nothing in Output > Python).
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- Create a new folder, and create
add.pyandtest.py - In
add.pyput:
def add(a, b):
return a + b- In
tests.pyput:
import unittest
from add import add
class TestAdd(unitest.TestCase):
def test_one_plus_one(self):
self.assertEqual(2, add(1, 1))- Using Testing on the sidebar select Set-up python tests > unittest > . > test*.py
- Run the tests, tests work normally ✅
- Add
unitest.main()to the bottom oftest.py. - Run
test.pywithpython test.py: tests work normally ✅ - Try running tests with the Testing side bar: tests do not work, and you get the error described above ❌
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
None
Metadata
Metadata
Assignees
Labels
area-testingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug