Pytest run all tests, not singles
See original GitHub issueEnvironment data
- VS Code version: 1.34.0
- Extension version (available under the Extensions sidebar): 2019.4.2
- OS and version: Ubuntu 18.04
- Python version (& distribution if applicable, e.g. Anaconda): 3.6
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Relevant/affected Python packages and their versions: –
Expected behaviour
Running a single test method should run it and not all method.
Actual behaviour
Running a test method run all the tests methods.
I have an idea of where the problem is: The item getted in my script seems not to be in the right order:
The dburlexpected param shuold be an URI and it is getted as the path of tests : 'tests/db_datapumping_urban_eco/test_db_preparator.py::test_tables_to_keep
If we run all the tests, it works perfectly fine.
moreover, if I run a single test with cli in a terminal , it works perfectly
Steps to reproduce:
- Install Python36, make a venv, call pytest with requests parameters.
- Config pytest in vcode to run with multiples arguments. (example: my config file)
- Run single tests or test file.
Config
settings.json (project)
{
"python.pythonPath": "venv/bin/python3",
"python.formatting.provider": "black",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.testing.pyTestArgs": [
"tests/db_datapumping_urban_eco/",
"--dburl",
"postgresql://postgres:postgres@localhost:5432/dev_in",
"--dburl-src",
"postgresql://postgres:postgres@localhost:5432/dev_src",
"--dburl-out",
"postgresql://postgres:postgres@localhost:5432/dev_out"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true
}
Logs
I refuse to pu logs for confidentiallity, but this part can be shown and is usefll
E ValueError: The param 'dburl' must match with '^[\w+]+://(\w+)(?::(\w+))?@([^/:]+)(?::(\d+))?(?:/(\w*))?$', got 'tests/my_script/test_my_script_worker.py::test_generating_single_conn_if_same_dburl'
-------------- generated xml file: /tmp/tmp-18547QrRuTLLFZce9.xml --------------
===================== 10 passed, 6 error in 41.98 seconds ======================
Thanks for your help, testing is very important in development workflow!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9
Top Results From Across the Web
With pytest, why are single test results different from running ...
The weird thing is, if I run all tests within a directory, all the tests pass. If I try to run a single...
Read more >How to invoke pytest — pytest documentation
In general, pytest is invoked with the command pytest (see below for other ways to invoke pytest). This will execute all tests in...
Read more >Pytest Tutorial: Executing Multiple Test Cases From Single File
With pytest you can run multiple test cases from a single file, or even run selective tests with custom markers or by grouping...
Read more >Run set of tests - MATLAB runtests - MathWorks
This MATLAB function runs all the tests in your current folder and returns the results as a ... Run the test elements that...
Read more >Effective Python Testing With Pytest
To run all tests except those that require database access, you can use pytest -m "not database_access" . You can even use an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here.
And I can reproduce with a simple snippet:
And add extra args to
python.testing.pyTestArgs
in.vscode/settings.json
:If I click
Run Test
abovetest_case_three
, pytest run all tests plus one moretest_case_three
.Output:
But it works fine with only one argument here.
So how does plugin pass args to pytest ?
validated