One thing that surprised me when I first tried to understand HA code through the testing code, is that some test_*.py files (172 actually) have thousands lines of code (I even saw some with 5000+ lines). This makes it ... so ... hard to go through it because there is no visible organisation or grouping of what part of the component you test at what stage. Let alone the fact that it puts my IDE on its knees... Where I come from, we make it nearly mandatory to group tests in smaller files, grouping them by areas or even sub areas they are testing, which makes it much easier to navigate.
I proposed the PR https://github.com/home-assistant/core/pull/105036 to work on it but the answer was that it was not the standard and that tests are grouped by module, not by functionality. I might have interpreted that as a definite "no" a bit quickly, without offering an alternative (even though I am a newbie and I am conscious I don't have any legitimacy around HA, at least not yet π π) .
So just wanted to check here and make another proposal before I bother anyone asking to review a modified PR.
Proposal
Would it be ok/a good idea to split the tests, but this time grouping them by modules as a directory with tests files in it?
The parts of the module being tested become instantaneously clearer.
Much easier to navigate and understand, especially for newcomers who want to participate. This decreases the price of the entry ticket.
IDEs are more responsive and support feature appear faster
Tests outputs are better compartimentized and one would immediately see which set of tests break (did not show breaking tests in the screenshots, but I guess you would get the point):
Context
I was told on Discord's dev channel that this was probably the place to put my question/proposal.
One thing that surprised me when I first tried to understand HA code through the testing code, is that some
test_*.py
files (172 actually) have thousands lines of code (I even saw some with 5000+ lines). This makes it ... so ... hard to go through it because there is no visible organisation or grouping of what part of the component you test at what stage. Let alone the fact that it puts my IDE on its knees... Where I come from, we make it nearly mandatory to group tests in smaller files, grouping them by areas or even sub areas they are testing, which makes it much easier to navigate.I proposed the PR https://github.com/home-assistant/core/pull/105036 to work on it but the answer was that it was not the standard and that tests are grouped by module, not by functionality. I might have interpreted that as a definite "no" a bit quickly, without offering an alternative (even though I am a newbie and I am conscious I don't have any legitimacy around HA, at least not yet π π) .
So just wanted to check here and make another proposal before I bother anyone asking to review a modified PR.
Proposal
Would it be ok/a good idea to split the tests, but this time grouping them by modules as a directory with tests files in it?
Instead of:
... We would end up with something along the lines of:
Consequences