-
Notifications
You must be signed in to change notification settings - Fork 0
Update test coverage to 96% and fix test suite crash #34
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
Conversation
Add proper thread cleanup to ImageWorker.stop() with stop signals and queue timeout handling. Call worker.stop() in ComicViewer._quit() and add __del__ safety net. Add image_worker fixture to conftest.py for proper test teardown. Update test coverage threshold to 96% in pyproject.toml and reflect milestone in AGENTS.md, tasks.md, and TESTING.md documentation.
c0eb93d to
de82eb4
Compare
Remove autouse fixture and simplify cleanup. Fix _run() exception handling to break immediately on any exception instead of checking priority value. This prevents workers from trying to access destroyed app state during teardown.
Add try/finally blocks to ensure ImageWorker.stop() is called before Tk root destruction in all tests that create workers manually. This prevents threads stuck in queue.get() from causing CI crashes. - tests/test_parallel_workers.py: Add cleanup to 10 tests - tests/test_threading.py: Add cleanup to 4 tests - tests/test_benchmark_parallel.py: Add cleanup to 2 tests
Replace try/finally blocks with Pythonic context manager for ImageWorker. This reduces boilerplate and makes cleanup automatic and explicit. - Add __enter__ and __exit__ methods to ImageWorker - Update 16 tests to use 'with ImageWorker() as worker:' pattern - Remove 57 lines of try/finally boilerplate
- Add assert app is not None after null check to satisfy pyright - Add source=None check in worker loop for graceful shutdown - Add test_worker_handles_none_source_gracefully to cover shutdown path - Coverage now at 96.00% (target reached) - All linting passes with 0 type checking errors
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
af85c83 to
1c8d699
Compare
6a03362 to
b3e94fd
Compare
- Add tests for request_page early return when stopped - Add tests for request_page when app is None - Add tests for queue.Full exception handling - Add tests for context manager behavior - Add tests for cleanup() method
- Add test for __del__ method calling cleanup - Add test for after_idle exception handling - Add test for general exception in worker - Add test for queue.Full exception in stop() - Add test for thread.join exception in stop() - Add test for worker stopping mid-processing
Extracted stop-check into _should_stop() method to enable reliable test coverage of thread interruption points without race conditions. Added 5 tests covering stop behavior at different processing stages. Fixed Tk cleanup in conftest.
|
John Cupitt | John Cupitt | 6:19 AM (2 hours ago) | |
-- | -- | -- | -- | --
John Cupitt
@jcupitt commented on this pull request. Other:
In pyvips/generate_type_stubs.py: > + def set_kill(self, kill: bool) -> None: ... + def copy(self, **kwargs: object) -> Image: ... + def tolist(self) -> List[List[float]]: ... + # numpy is optional dependency - use TYPE_CHECKING guard + def __array__(self, dtype: Optional[str] = None, copy: Optional[bool] = None) -> object: ... + def numpy(self, dtype: Optional[str] = None) -> object: ... + + # Dynamically generated operations +''' + + stub += generate_all_image_operations() + + stub += """ + + # Operator overloads + def __add__(self, other: Union[Image, float, int]) -> Image: ... You can have arrays of float and int too, eg. In pyvips/generate_type_stubs.py: > + def __or__(self, other: Union[Image, float, int]) -> Image: ... + def __ror__(self, other: Union[Image, float, int]) -> Image: ... + def __xor__(self, other: Union[Image, float, int]) -> Image: ... + def __rxor__(self, other: Union[Image, float, int]) -> Image: ... + def __eq__(self, other: object) -> bool: ... + def __ne__(self, other: object) -> bool: ... + def __gt__(self, other: Union[Image, float, int]) -> Image: ... + def __ge__(self, other: Union[Image, float, int]) -> Image: ... + def __lt__(self, other: Union[Image, float, int]) -> Image: ... + def __le__(self, other: Union[Image, float, int]) -> Image: ... + + def __getitem__(self, arg: Union[int, slice, List[int], List[bool]]) -> Image: ... + def __call__(self, x: int, y: int) -> List[float]: ... + def __repr__(self) -> str: ... + + There are a set of hand-written bindings too, perhaps some of them could have type hints? Easy: Medium: Horrible: — 6:19 AM (2 hours ago) to libvips/pyvips, me, Mention @jcupitt commented on this pull request. Other: In pyvips/generate_type_stubs.py:
+'''
You can have arrays of float and int too, eg. a + [1, 2, 3] adds 1 to band 0, 2 to band 1, 3 to band 2. In pyvips/generate_type_stubs.py:
There are a set of hand-written bindings too, perhaps some of them could have type hints? Easy: image.floor() etc. Medium: bandjoin, bandsplit, composite etc. Horrible: ifthenelse. — |
Summary
Testing
All 413 tests pass with 96.59% coverage:
uv run pytest --cov=cdisplayagain --cov-report=term-missingChanges