Skip to content

fix(flet-charts): drop stray tests/__init__.py that broke test collection#6722

Merged
FeodorFitsner merged 1 commit into
mainfrom
fix-charts-tests-import-collision
Jul 25, 2026
Merged

fix(flet-charts): drop stray tests/__init__.py that broke test collection#6722
FeodorFitsner merged 1 commit into
mainfrom
fix-charts-tests-import-collision

Conversation

@FeodorFitsner

Copy link
Copy Markdown
Contributor

Fixes the Python test job failing on main across every Python version (3.10–3.14) — e.g. run 30175601817.

The failure

ERROR collecting packages/flet-charts/tests/test_matplotlib_chart_canvas.py
ModuleNotFoundError: No module named 'tests.test_matplotlib_chart_canvas'
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!

Cause

packages/flet/tests/ and packages/flet-charts/tests/ both contained 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, which sorts first in the packages/*/tests glob) is what lands in sys.modules as tests; 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__.py was added in #6710.

Fix

Remove packages/flet-charts/tests/__init__.py.

  • packages/flet/tests/__init__.py has to stay: test_object_diff_in_place.py and test_object_diff_frozen.py use from .common import ..., which needs the package.
  • The flet-charts test only uses absolute imports (from flet_charts... import ...), so it never needed the package. Without __init__.py it's imported as a bare basename module, matching packages/flet-cli/tests and packages/flet-mcp/tests, neither of which has one.

Verification

Ran the exact CI invocation locally:

$ uv run --no-dev --group test pytest packages/*/tests
351 passed, 8 skipped

and confirmed the flet-charts tests actually execute rather than being skipped:

$ uv run --no-dev --group test pytest packages/flet-charts/tests
4 passed

Note

Test basenames are currently unique repo-wide, so prepend mode is fine. If duplicate test filenames ever show up across packages, the durable fix is --import-mode=importlib in [tool.pytest.ini_options] — out of scope for this hotfix.

…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.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

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

View logs

@FeodorFitsner
FeodorFitsner merged commit b9d3844 into main Jul 25, 2026
31 of 94 checks passed
@FeodorFitsner
FeodorFitsner deleted the fix-charts-tests-import-collision branch July 25, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant