Skip to content

Pytest test discovery confused by packages #3936

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
Flamefire opened this issue Jan 9, 2019 · 9 comments
Closed

Pytest test discovery confused by packages #3936

Flamefire opened this issue Jan 9, 2019 · 9 comments
Labels
area-testing bug Issue identified by VS Code Team member as probable bug

Comments

@Flamefire
Copy link

Environment data

  • VS Code version: 1.30.2
  • Extension version (available under the Extensions sidebar): 2018.12.1
  • Relevant/affected Python packages and their versions: pytest 3.9.1

Expected behaviour

Tests are discovered correctly

Actual behaviour

Any package causes subsequently discovered tests to be considered IN the package

Steps to reproduce:

  1. Create a tests folder
  2. Create test/testa/test_first.py test/testc/test_last.py with regular python tests (any function will suffice)
  3. Create test/testb/init.py and test/testb/test_second.py with a python test function
  4. Run discover tests

Logs

Example pytest output:

============================= test session starts ==============================
platform linux -- Python 3.6.0, pytest-3.9.1, py-1.7.0, pluggy-0.8.0
Using --randomly-seed=1547049040
rootdir: /home/alex/git/HP-DLF, inifile:
plugins: repeat-0.7.0, randomly-1.2.3, profiling-1.3.0, cov-2.6.0, console-scripts-0.1.7, nbval-0.9.1
collected 3 items
<Module 'test/testa/test_first.py'>
  <Function 'test_foo'>
<Package '/home/.../test/testb'>
  <Module 'test_second.py'>
    <Function 'test_foo'>
<Module 'test/testc/test_last.py'>
  <Function 'test_foo'>

========================= no tests ran in 0.11 seconds =========================

The test output parser will report the last one in file /home/.../test/testb/test/testc/test_last.py which is clearly wrong.

Reason is that the packagePrefix is not reset

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jan 9, 2019
@DonJayamanne DonJayamanne self-assigned this Jan 9, 2019
@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug needs PR area-testing labels Jan 9, 2019
@ghost ghost removed triage-needed Needs assignment to the proper sub-team labels Jan 9, 2019
@Flamefire
Copy link
Author

I have a solution for this and can open a PR.

Flamefire added a commit to Flamefire/vscode-python that referenced this issue Jan 9, 2019
Flamefire added a commit to Flamefire/vscode-python that referenced this issue Jan 9, 2019
Flamefire added a commit to Flamefire/vscode-python that referenced this issue Jan 9, 2019
Flamefire added a commit to Flamefire/vscode-python that referenced this issue Feb 8, 2019
@DonJayamanne
Copy link

@ericsnowcurrently Please ensure your python code works in this scenario, if it does, then we can close this.
Just need to ensure this gets tracked and tested, hence assigning to you & myself.

@DonJayamanne DonJayamanne self-assigned this Feb 27, 2019
@Flamefire
Copy link
Author

Feel free to give me a ping once #4605 is used so I can check against my test tree if it works too.

Flamefire added a commit to Flamefire/vscode-python that referenced this issue Mar 6, 2019
Flamefire added a commit to Flamefire/vscode-python that referenced this issue Mar 21, 2019
@ericsnowcurrently ericsnowcurrently removed their assignment Apr 2, 2019
@sleighsoft
Copy link

sleighsoft commented Apr 9, 2019

Any time frame on when this will be released? It currently makes the pytest integration unusable for me.

@Flamefire
Copy link
Author

I compiled the latest master locally and for me it is working. If it isn't for you you may watch #4795 which seems to contain the actual implementation of the Python based discovery.

@sleighsoft
Copy link

Thanks @Flamefire. I just don't want to spend time compiling. I hope they supply an update soon.

@sleighsoft
Copy link

Seems to have not made it into release 1.33.1 :/

@thatbudakguy
Copy link

Can we get an update on when this will be released?

@ericsnowcurrently ericsnowcurrently removed their assignment Sep 3, 2019
@ericsnowcurrently
Copy link

This should be resolved in the most recent versions of the Python extension. If that is not the case then please create a new issue. (This one has a bit of outdated info, so better to start fresh.)

@ghost ghost removed the needs PR label Sep 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 10, 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

5 participants