Add Pytest.
π Feature Request: Improve Test Coverage for pycht
We currently have a good base of unit tests for the core functionalities in:
pycht/clustering.pypycht/image_processing.py
However, to ensure long-term stability and improve confidence during refactoring, we should expand the test coverage.
β What Needs Testing
Here are some suggestions for additional test cases:
π§ Clustering
- [ ] Test with
nb_clusters=1(should return uniform output). - [ ] Test with more clusters than unique colors (e.g. 5 clusters, 3 colors).
- [ ] Test invalid input: wrong shape or non-float data.
- [ ] Test edge case with an empty array.
πΌ ImageProcessing
- [ ] Add test for
process()method (check shape and dtype). - [ ] Add test for invalid image paths (should raise
FileNotFoundError). - [ ] Add test to ensure saved stencil images have correct dimensions and color formats.
π§ͺ Notes
- Tests should be added under the
tests/folder following the current naming/style conventions. - Use
pytestfixtures when appropriate for clean setup/teardown. - Be sure to test both happy paths and edge cases.
π Checklist
- [ ] Add at least 3 new tests for
Clustering - [ ] Add at least 3 new tests for
ImageProcessing - [ ] Ensure all new tests pass with
pytest - [ ] Follow existing formatting and naming conventions
- [ ] Link your PR to this issue
Feel free to grab a task and open a PR! Letβs make pycht rock-solid π§±π¨
Hi ππΎ
I think I'll take this one. I would like to do some refactorings later and it's better if we have at least some unit tests.
Of course, we can use pytest plugin for the code coverage.
Do you have some ideas about unit tests writing for the existing code @tlentali ?
Thanks @garaud ! While looking for ideas about unit tests writing, I made a branch to have a basic test structure that I merged with main. So now we have very basic test running each time we push on main. Clearly a lot of test are missing, do you want to have a look ?
Clearly a lot of test are missing, do you want to have a look ?
Yes thank you, I'll do that :)
FYI, I just replaced opencv-python to pillow so I replaced its basic unit test to check it. This replacement will lighten the package.