Skip to content

"Run Current Test File" only runs one test in file #7389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
memeplex opened this issue Sep 13, 2019 · 1 comment
Closed

"Run Current Test File" only runs one test in file #7389

memeplex opened this issue Sep 13, 2019 · 1 comment
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@memeplex
Copy link

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:

  1. Create a workspace with one single folder and a test_simple.py file below
  2. Add the code quoted below to this file
  3. Check that the tests are discovered
  4. Select "Run Current Test File" from the context menu
  5. 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:

image

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

@memeplex memeplex added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Sep 13, 2019
@kimadeline
Copy link

Duplicate of #4567

@kimadeline kimadeline marked this as a duplicate of #4567 Sep 13, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 13, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants