Skip to content

Execute the current unittest file not executing all tests #4567

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
Ronkiro opened this issue Feb 27, 2019 · 9 comments
Closed

Execute the current unittest file not executing all tests #4567

Ronkiro opened this issue Feb 27, 2019 · 9 comments
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug

Comments

@Ronkiro
Copy link

Ronkiro commented Feb 27, 2019

Environment data

  • VS Code version: 1.31.1
  • Extension version (available under the Extensions sidebar): 2019.2.5416
  • OS and version: W10 Enterprise 10.0.17134
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: Extension

Expected behaviour

Run all unittests on file

Actual behaviour

Runs only the first unittest.

Steps to reproduce:

  1. Create an unittest class. (class Class(unittest.TestCase):)
  2. Add a method to test.
  3. Add another method to test.
  4. Click right mouse button.
  5. Click "Execute the current unittest file" (Translated from Portuguese, not sure if it's exactly how it shows.
  6. Just the first test will execute, ignoring all others.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

test_instancia (test.test_api_infobip.InfobipTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.001s

OK

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Programas\servicosmsf_v2
console.ts:134 [Extension Host] Python Extension: Cached data exists ActivatedEnvironmentVariables, c:\Programas\servicosmsf_v2
console.ts:134 [Extension Host] Python Extension: getActivatedEnvironmentVariables, Class name = b, Arg 1: <Uri:c:\Programas\servicosmsf_v2>, Arg 2: undefined
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, c:\Programas\servicosmsf_v2
console.ts:134 [Extension Host] Python Extension: Cached data exists getEnvironmentVariables, extension-output-#5
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Feb 27, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Feb 27, 2019
@DonJayamanne DonJayamanne self-assigned this Feb 27, 2019
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug needs PR area-testing labels Feb 28, 2019
@DonJayamanne DonJayamanne removed their assignment Feb 28, 2019
@damonallison
Copy link

damonallison commented Apr 12, 2019

+1 - I ran into this as well.

From the Test Side Bar, running tests from the .py file will only run the first test (which I assume the "Python: Run Current Unit Test File" does.

Screen Shot 2019-04-12 at 5 45 32 AM

Running tests at the class level will execute all tests in the class.

Screen Shot 2019-04-12 at 5 53 35 AM

Hope this helps.

@DonJayamanne
Copy link

@damonallison

Please could you provide some sample code we can use to repro the issues at our end?
Thanks

@damonallison
Copy link

@DonJayamanne

You bet - run the tests in this repo. https://github.com/damonallison/python-examples

The screenshots I posted were from this repo, so they should look familiar. Let me know if you're not able to repro it. Thanks!

@DonJayamanne
Copy link

Awesome, I can replicate this at my end, thanks.

@kondratyev-nv
Copy link

I've run at this issue as well. I've created a file test_add.py with the following tests

import unittest


class AddTests(unittest.TestCase):
    def test_two_plus_one_is_three(self):
        self.assertEqual(3, 2 + 1)

    def test_two_plus_two_is_five(self):
        self.assertEqual(5, 2 + 2)

    def test_two_plus_zero_is_two(self):
        self.assertEqual(2, 2 + 0)

And in the logs I can see that command line specifies the test to run.

> C:\Python27\python.exe c:\Users\<###>\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\visualstudio_py_testlauncher.py --us=. --up=*test*.py --uvInt=2 --result-port=53405 -ttest_add.AddTests.test_two_plus_one_is_three --testFile=<###>\sample\test_add.py
cwd: <###>\sample
> C:\Python27\python.exe c:\Users\<###>\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\visualstudio_py_testlauncher.py --us=. --up=*test*.py --uvInt=2 --result-port=53405 -ttest_add.AddTests.test_two_plus_one_is_three --testFile=<###>\sample\test_add.py
cwd: <###>\sample

By the log it looks like the file node has an incorrect nameToRun value, so I've modified TestsParser for unittest. Please see PR #7783.

@ericsnowcurrently
Copy link

@kondratyev-nv, FYI I plan on taking a look at your PR in the next few days.

@kondratyev-nv
Copy link

Thank you! I look forward to it.

@karrtikr
Copy link

karrtikr commented Nov 7, 2019

Validated, thanks again @kondratyev-nv

@karrtikr karrtikr closed this as completed Nov 7, 2019
@ghost ghost removed the needs PR label Nov 7, 2019
@ericsnowcurrently
Copy link

@luabud, happy now? 😁️

@lock lock bot locked as resolved and limited conversation to collaborators Nov 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

9 participants