Closed
Description
Environment data
- VS Code version: 1.38.1
- Extension version: 2019.9.34911
- OS and version: Ubuntu 19.04
- Python version: 3.7.3
- Type of virtual environment: N/A
- Relevant/affected Python packages and their versions: unittest (builtin)
- Jedi or Language Server?: Jedi
Expected behaviour
All unit tests in the file are run. Alternatively, current test (the one where the cursor is) in the file is run.
Actual behaviour
Only the first test in the file is run.
Steps to reproduce:
- Create a workspace with one single folder and a
test_simple.py
file below - Add the code quoted below to this file
- Check that the tests are discovered
- Select "Run Current Test File" from the context menu
- Check the test output log or the Test view in the side panel
from unittest import TestCase
class SimpleTest(TestCase):
def test_one(self):
self.assertEqual(1, 1)
def test_two(self):
self.assertEqual(2, 2)
Here is an screenshot:
Logs
Output for Python Test Log
in the Output
panel
start
start
start
start
test_simple.SimpleTest.test_one
test_simple.SimpleTest.test_two
start
test_simple.SimpleTest.test_one
test_simple.SimpleTest.test_two
test_one (test_simple.SimpleTest) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
start
test_simple.SimpleTest.test_one
test_simple.SimpleTest.test_two
test_one (test_simple.SimpleTest) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Output for Python
in the Output
panel
User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> conda info --json
Starting Jedi Python language engine.
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> conda info --json
> conda --version
> /usr/bin/python3 -c "import sys;print(sys.prefix)"
cwd: /tmp/test
> /usr/bin/python3 -c "import sys;print(sys.prefix)"
cwd: /tmp/test
> /usr/bin/python3 -c "import sys;print(sys.executable)"
cwd: /tmp/test
> /usr/bin/python3 -c "import sys;print(sys.executable)"
cwd: /tmp/test
> /usr/bin/python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: /tmp/test
> /usr/bin/python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: /tmp/test
> /usr/bin/python3 -m site --user-site
cwd: /tmp/test
> /usr/bin/python3 -m site --user-site
cwd: /tmp/test
> /usr/bin/python3 completion.py
cwd: ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles
> /usr/bin/python3 completion.py
cwd: ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test.py
cwd: /tmp/test
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test.py
cwd: /tmp/test
##########Linting Output - flake8##########
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test.py
cwd: /tmp/test
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test.py
cwd: /tmp/test
##########Linting Output - flake8##########
5,1,W,W293:blank line contains whitespace
8,1,W,W293:blank line contains whitespace
10,31,W,W292:no newline at end of file
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test.py
cwd: /tmp/test
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test.py
cwd: /tmp/test
##########Linting Output - flake8##########
10,31,W,W292:no newline at end of file
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test_simple.py
cwd: /tmp/test
> /usr/bin/python3 -m flake8 --format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s /tmp/test/test_simple.py
cwd: /tmp/test
##########Linting Output - flake8##########
10,31,W,W292:no newline at end of file
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/visualstudio_py_testlauncher.py --us=. --up=test_*.py --uvInt=2 --result-port=38965 -ttest_simple.SimpleTest.test_one --testFile=/tmp/test/test_simple.py
cwd: /tmp/test
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/visualstudio_py_testlauncher.py --us=. --up=test_*.py --uvInt=2 --result-port=38965 -ttest_simple.SimpleTest.test_one --testFile=/tmp/test/test_simple.py
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 -c "
import unittest
loader = unittest.TestLoader()
suites = loader.discover(".", pattern="test_*.py")
print("start") #Don't remove this line
for suite in suites._tests:
for cls in suite._tests:
try:
for m in cls._tests:
print(m.id())
except:
pass"
cwd: /tmp/test
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/visualstudio_py_testlauncher.py --us=. --up=test_*.py --uvInt=2 --result-port=42159 -ttest_simple.SimpleTest.test_one --testFile=/tmp/test/test_simple.py
cwd: /tmp/test
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/visualstudio_py_testlauncher.py --us=. --up=test_*.py --uvInt=2 --result-port=42159 -ttest_simple.SimpleTest.test_one --testFile=/tmp/test/test_simple.py
cwd: /tmp/test
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/visualstudio_py_testlauncher.py --us=. --up=test_*.py --uvInt=2 --result-port=36677 -ttest_simple.SimpleTest --testFile=/tmp/test/test_simple.py
cwd: /tmp/test
> /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/visualstudio_py_testlauncher.py --us=. --up=test_*.py --uvInt=2 --result-port=36677 -ttest_simple.SimpleTest --testFile=/tmp/test/test_simple.py
cwd: /tmp/test