Skip to content

Commit

Permalink
Update tests README with extra info on config
Browse files Browse the repository at this point in the history
Debugging tests wasn't working, and it's because generating code coverage while debugging breaks debugging.
  • Loading branch information
gcglinton committed Jul 26, 2023
1 parent f05a7ab commit 6c04c60
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ If you want to run this in VSCode, and have it do all the things nicely, you'll
- [GitLens — Git supercharged](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)
Not strictly required, but *very* strongly recommended as it makes VS Code's git features fully functional

Beyond that, changing a few options in your settings file will make it all work; thusly:
Beyond that, changing a few things in your VS Code configs will make it all work.

In `settings.json`, to get all the reports and coverage when running tests, and allow you to run individual tests even if they have dependencies:
```json
{
"python.testing.pytestArgs": [
"tests", "-v",
"--cov-config=tests/.coveragerc", "--cov=sarracenia", "--cov-report=xml", "--cov-report=html",
"--html=tests/report.html", "--self-contained-html",
"--failed-dependency-action=run", "--missing-dependency-action=run"
],
"python.testing.unittestEnabled": false,
Expand All @@ -69,6 +72,28 @@ Beyond that, changing a few options in your settings file will make it all work;
}
```


In `launch.json` (per [documentation](https://code.visualstudio.com/docs/python/testing#_debug-tests)), to enable full debugging support in your tests:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"program": "${file}",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false,
"env": {"PYTEST_ADDOPTS": "--no-cov"}
}
]
}
```

**NOTE:** Don't just squash whatever you have in `settings.json`, or `launch.json`, but use some common sense to merge what's above into your existing files.

## Docker
You can also run the exact same tests from within a Docker container if you want to avoid having to (re)-provision clean installs.

Expand Down

0 comments on commit 6c04c60

Please sign in to comment.