pycht icon indicating copy to clipboard operation
pycht copied to clipboard

Add Pytest.

Open tlentali opened this issue 9 months ago β€’ 4 comments

πŸ“Œ Feature Request: Improve Test Coverage for pycht

We currently have a good base of unit tests for the core functionalities in:

  • pycht/clustering.py
  • pycht/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 pytest fixtures 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 🧱🎨

tlentali avatar Mar 28 '25 02:03 tlentali

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 ?

garaud avatar Apr 14 '25 15:04 garaud

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 ?

tlentali avatar Apr 17 '25 18:04 tlentali

Clearly a lot of test are missing, do you want to have a look ?

Yes thank you, I'll do that :)

garaud avatar Apr 18 '25 07:04 garaud

FYI, I just replaced opencv-python to pillow so I replaced its basic unit test to check it. This replacement will lighten the package.

tlentali avatar Apr 18 '25 12:04 tlentali