-
Notifications
You must be signed in to change notification settings - Fork 6
[Documentation] Add test coverage guidance for integration tests #967
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,25 @@ Typical error messages related to missing dependencies are `ModuleNotFoundError` | |||||
| * `ModuleNotFoundError: No module named 'h5py'` - Install [h5py](https://www.h5py.org/) as explained in the [Caching](https://executorlib.readthedocs.io/en/latest/installation.html#caching) section of the installation. | ||||||
| * `ModuleNotFoundError: No module named 'networkx'` - Install [networkx](https://networkx.org/) as explained in the [Visualisation](https://executorlib.readthedocs.io/en/latest/installation.html#visualisation) section of the installation. | ||||||
|
|
||||||
| ## Test Coverage for Integration Tests | ||||||
| When Python functions are executed with executorlib, they run in subprocesses started via `sys.executable`. As a result, `coverage run` | ||||||
| only tracks the main test process by default and can miss function execution inside executorlib workers. | ||||||
|
|
||||||
| To collect coverage from both the main process and executorlib subprocesses, enable the subprocess patch in your project configuration: | ||||||
| ```toml | ||||||
| [tool.coverage.run] | ||||||
| patch = ["subprocess"] | ||||||
| ``` | ||||||
|
Comment on lines
+39
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Yes, coverage.py supports a "patch" configuration option under the [run] section for subprocess tracking. The correct configuration to track subprocess execution is: [patch] subprocess = true This automatically sets parallel = true, so use coverage combine before reporting. It works for processes created with subprocess, os.system, or execv/spawnv functions (ensuring COVERAGE_PROCESS_START is passed for env variants). Example .coveragerc: [run] patch = subprocess Then: coverage run ..., coverage combine, coverage report. For multiprocessing, use concurrency = multiprocessing instead. Citations:
Fix TOML syntax for subprocess tracking configuration. The correct coverage.py configuration is [tool.coverage.run]
patch = subprocessThe 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| Then execute: | ||||||
| ```bash | ||||||
| coverage run -m unittest discover | ||||||
|
||||||
| coverage run -m unittest discover | |
| coverage run -m unittest discover tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coverage config snippet enables the subprocess patch, but it doesn’t mention enabling parallel data files. Without
parallel = true(or an equivalent mechanism), multiple worker processes can end up writing to the same.coveragedata file andcoverage combinemay be ineffective. Consider addingparallel = trueto the[tool.coverage.run]example alongsidepatch = ["subprocess"].