🧹 Test Suite Cleanup: Permanent Issue
Hi there! This issue is a permanent issue dedicated as a hub for efforts to improve the quality of the test suite. If you have questions talk to the community on our Discord server.
If you have a question about a particular issue, or pull request just tag @python-poetry/triage in a comment.
This is a great issue to work on if you are new to the Poetry code base and want to start contributing. Over the years the Poetry test suite has grown significantly -- this means that there is significant a amount of code duplication that is hard to maintain and inefficient .
If you are submitting a pull request associated with this, please keep the pull requests small and modular. This means, do not do too much in one PR and try to do only closely related changes in on PR. Additionally, make sure you add Relates-to: (not Closes: or Fixes: or Resolves:) to your PR description.
Relates-to: #3155
If this is your first contribution here, please refer to #3061 before continuing.
Ongoing Improvements
Convert reused code/logic into fixtures
There is a significant amount of code and data duplication in the test suite that can be converted to pytest fixtures.
Adding coverage
There are certain code paths within the codebase that may not necessarily be covered within the test suite. You can.
a) Find them, and raise an issue to cover them. b) (a) and also write some tests.
Known missing:
- [ ]
poetry buildcommand.
Improve Parallel Safety
Presently, because a lot of tests generate and cleanup package metadata, or share resources the tests suite is not parallel execution safe. Any improvements towards this goal is always welcome. Most of this will be covered by proper use of fixtures, but identifying shared file resources being used and working on on-write copies would go a long way in this goal.
UPDATED: January 27th '24 As of today, our test coverage looks like this (skipped files with 100% coverage):
Name Stmts Miss Cover
--------------------------------------------------------------------------------
src/poetry/__main__.py 5 5 0%
src/poetry/config/config.py 184 3 98%
src/poetry/config/config_source.py 7 2 71%
src/poetry/config/dict_config_source.py 29 1 97%
src/poetry/config/file_config_source.py 57 38 33%
src/poetry/console/application.py 205 11 95%
src/poetry/console/command_loader.py 9 1 89%
src/poetry/console/commands/add.py 133 3 98%
src/poetry/console/commands/cache/clear.py 49 9 82%
src/poetry/console/commands/check.py 78 2 97%
src/poetry/console/commands/command.py 27 3 89%
src/poetry/console/commands/config.py 166 7 96%
src/poetry/console/commands/debug/resolve.py 81 13 84%
src/poetry/console/commands/env/info.py 36 2 94%
src/poetry/console/commands/env/list.py 20 1 95%
src/poetry/console/commands/env/remove.py 26 1 96%
src/poetry/console/commands/env/use.py 16 2 88%
src/poetry/console/commands/init.py 244 12 95%
src/poetry/console/commands/installer_command.py 18 3 83%
src/poetry/console/commands/new.py 44 3 93%
src/poetry/console/commands/publish.py 27 6 78%
src/poetry/console/commands/remove.py 72 9 88%
src/poetry/console/commands/run.py 47 2 96%
src/poetry/console/commands/self/install.py 12 1 92%
src/poetry/console/commands/self/self_command.py 72 2 97%
src/poetry/console/commands/self/show/__init__.py 15 4 73%
src/poetry/console/commands/self/show/plugins.py 64 2 97%
src/poetry/console/commands/self/update.py 27 2 93%
src/poetry/console/commands/show.py 286 13 95%
src/poetry/console/commands/source/add.py 74 3 96%
src/poetry/console/commands/version.py 59 2 97%
src/poetry/console/io/inputs/run_argv_input.py 50 7 86%
src/poetry/console/logging/formatters/builder_formatter.py 14 9 36%
src/poetry/console/logging/formatters/formatter.py 4 1 75%
src/poetry/console/logging/io_formatter.py 19 11 42%
src/poetry/console/logging/io_handler.py 17 9 47%
src/poetry/factory.py 199 9 95%
src/poetry/inspection/info.py 294 20 93%
src/poetry/inspection/lazy_wheel.py 294 23 92%
src/poetry/installation/chef.py 112 3 97%
src/poetry/installation/chooser.py 86 13 85%
src/poetry/installation/executor.py 530 57 89%
src/poetry/installation/installer.py 223 11 95%
src/poetry/installation/operations/install.py 17 2 88%
src/poetry/installation/operations/operation.py 39 8 79%
src/poetry/installation/operations/uninstall.py 17 2 88%
src/poetry/installation/operations/update.py 28 6 79%
src/poetry/installation/wheel_installer.py 53 6 89%
src/poetry/layouts/__init__.py 8 1 88%
src/poetry/layouts/layout.py 111 5 95%
src/poetry/locations.py 24 7 71%
src/poetry/masonry/api.py 7 7 0%
src/poetry/masonry/builders/editable.py 140 16 89%
src/poetry/mixology/failure.py 136 31 77%
src/poetry/mixology/incompatibility.py 250 38 85%
src/poetry/mixology/incompatibility_cause.py 37 3 92%
src/poetry/mixology/partial_solution.py 93 3 97%
src/poetry/mixology/term.py 82 10 88%
src/poetry/mixology/version_solver.py 217 1 99%
src/poetry/packages/dependency_package.py 29 2 93%
src/poetry/packages/direct_origin.py 50 3 94%
src/poetry/packages/locker.py 279 6 98%
src/poetry/plugins/base_plugin.py 8 1 88%
src/poetry/plugins/plugin.py 9 1 89%
src/poetry/plugins/plugin_manager.py 36 1 97%
src/poetry/publishing/uploader.py 164 17 90%
src/poetry/puzzle/provider.py 432 46 89%
src/poetry/puzzle/solver.py 171 4 98%
src/poetry/pyproject/toml.py 35 1 97%
src/poetry/repositories/cached_repository.py 32 7 78%
src/poetry/repositories/http_repository.py 200 15 92%
src/poetry/repositories/installed_repository.py 142 6 96%
src/poetry/repositories/legacy_repository.py 51 4 92%
src/poetry/repositories/link_sources/base.py 77 1 99%
src/poetry/repositories/link_sources/html.py 40 1 98%
src/poetry/repositories/parsers/pypi_search_parser.py 46 1 98%
src/poetry/repositories/pypi_repository.py 112 9 92%
src/poetry/repositories/repository.py 65 10 85%
src/poetry/repositories/single_page_repository.py 11 4 64%
src/poetry/toml/file.py 26 1 96%
src/poetry/utils/_compat.py 27 5 81%
src/poetry/utils/authenticator.py 256 14 95%
src/poetry/utils/cache.py 164 3 98%
src/poetry/utils/dependency_specification.py 137 18 87%
src/poetry/utils/env/__init__.py 51 6 88%
src/poetry/utils/env/base_env.py 248 32 87%
src/poetry/utils/env/env_manager.py 414 39 91%
src/poetry/utils/env/generic_env.py 57 13 77%
src/poetry/utils/env/mock_env.py 45 5 89%
src/poetry/utils/env/null_env.py 33 1 97%
src/poetry/utils/env/site_packages.py 117 28 76%
src/poetry/utils/env/system_env.py 48 6 88%
src/poetry/utils/env/virtual_env.py 86 13 85%
src/poetry/utils/helpers.py 191 54 72%
src/poetry/utils/password_manager.py 147 11 93%
src/poetry/utils/pip.py 22 3 86%
src/poetry/utils/setup_reader.py 232 20 91%
src/poetry/utils/shell.py 106 73 31%
src/poetry/utils/wheel.py 26 1 96%
src/poetry/vcs/git/backend.py 254 170 33%
src/poetry/version/version_selector.py 19 1 95%
--------------------------------------------------------------------------------
TOTAL 11063 1144 90%
Posting as a guideline for those who would like to help with test coverage and cleanup