fix(flet-charts): drop stray tests/__init__.py that broke test collection#6722
Merged
Conversation
…tion `pytest packages/*/tests` (the CI invocation) failed on every Python version with: ERROR collecting packages/flet-charts/tests/test_matplotlib_chart_canvas.py ModuleNotFoundError: No module named 'tests.test_matplotlib_chart_canvas' packages/flet/tests and packages/flet-charts/tests both had an __init__.py, so under pytest's default 'prepend' import mode both directories claim the same top-level package name, 'tests'. The first one collected (packages/flet/tests) lands in sys.modules as 'tests', and every module under the other one is then looked up as a submodule of it and not found. packages/flet/tests needs its __init__.py -- test_object_diff_in_place.py and test_object_diff_frozen.py import 'from .common import ...'. The flet-charts test only uses absolute imports, so its __init__.py is unnecessary; removing it makes the module a bare basename, matching packages/flet-cli/tests and packages/flet-mcp/tests which never had one. Added in #6710. Verified: `uv run --no-dev --group test pytest packages/*/tests` now reports 351 passed, 8 skipped, and the four flet-charts tests run.
Deploying flet-website-v2 with
|
| Latest commit: |
d8051da
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://55c1069e.flet-website-v2.pages.dev |
| Branch Preview URL: | https://fix-charts-tests-import-coll.flet-website-v2.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the Python test job failing on
mainacross every Python version (3.10–3.14) — e.g. run 30175601817.The failure
Cause
packages/flet/tests/andpackages/flet-charts/tests/both contained an__init__.py, so under pytest's defaultprependimport mode both directories claim the same top-level package name —tests. The first one collected (packages/flet/tests, which sorts first in thepackages/*/testsglob) is what lands insys.modulesastests; every module under the other directory is then looked up as a submodule of it and isn't found.This is a collection-time error, so it aborted the whole run — nothing else got to execute.
packages/flet-charts/tests/__init__.pywas added in #6710.Fix
Remove
packages/flet-charts/tests/__init__.py.packages/flet/tests/__init__.pyhas to stay:test_object_diff_in_place.pyandtest_object_diff_frozen.pyusefrom .common import ..., which needs the package.from flet_charts... import ...), so it never needed the package. Without__init__.pyit's imported as a bare basename module, matchingpackages/flet-cli/testsandpackages/flet-mcp/tests, neither of which has one.Verification
Ran the exact CI invocation locally:
and confirmed the flet-charts tests actually execute rather than being skipped:
Note
Test basenames are currently unique repo-wide, so
prependmode is fine. If duplicate test filenames ever show up across packages, the durable fix is--import-mode=importlibin[tool.pytest.ini_options]— out of scope for this hotfix.