-
Notifications
You must be signed in to change notification settings - Fork 31
Move test-specific functions to tests #357
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
base: main
Are you sure you want to change the base?
Conversation
I didn't know that MNE-Python tests actually require these |
I think it's important and useful to continue testing on older versions of MNE-Python, so I don't think we should just update MNE-Python I can't think of any easy solutions offhand |
I would update MNE-Python tests and just keep the methods around until the oldest supported MNE-Python does not require them anymore. |
Is the idea to copy the How about a |
Not necessarily. I'd prefer if they still lived in this package, just not in the main |
Okay with me to have them live in |
Yes, this is basically what I already did here. I moved all functions except Can you elaborate how you would like to handle this at the MNE-Python end? Since One way around this would be to declare non-abstract (i.e., normal) methods in |
Oh sorry I hadn't looked that closely, didn't realize they were part of the abstract base class. I'd leave them in that case. Seems like more work than it's worth to move them around / out of the class. And it is kind of nice having both backends implement the same method, even if it is only used in tests. IIRC that was part of design decisions made by @drammock so he should probably weigh in too. |
I would strongly argue for separating the actual functionality from test functionality. |
What is the end goal here? IIUC, the proposal is to trade complexity in the class definition (having some extra private methods defined that aren't needed by users, only devs) for complexity somewhere else (mutating the class, by injecting those methods, prior to testing). I don't like that idea because it means that the class being tested is not the same class being used by users. Sure, I can look at the details of this PR and convince myself that it's fine right now, but it's a bad pattern to follow IMO. I also worry that it's extra cognitive overhead for new maintainers, who may look at a test and wonder "where is this (all of this is just in reference to this repo; the additional added complexity at the MNE-Python end seems like a pretty strong signal that this is not an improvement overall). If you're really really bothered by the test-only methods being defined alongside the other methods in one place, my advice would be: make sure all the test-only methods come at the end, and put a prominent code comment in the file to delineate the transition. If that's not good enough, another possibility (but seems like overkill to me) is to define a mixin class that has the testing methods in a different file, and have the main class inherit from it. Will either of those solutions work for you? |
I think it's a bad pattern to mix in test methods. This is not the purpose of that class. I don't like injecting either, I just did that because it was the least invasive solution. We could also subclass it and add the test methods that way. |
My general feeling aligns with @larsoner:
However: if we can get it to work cleanly, I am OK with eliminating those methods in the main class definition. I think maybe something like this might work:
|
This keeps the code base clean and also makes the class shorter.