braindecode
braindecode copied to clipboard
Can we get rid of code executed when importing test module?
Regarding https://github.com/braindecode/braindecode/blob/e7063545e7462fb50e216d7cd31020b36ae4d521/test/unit_tests/datautil/test_preprocess.py#L18-L26
Wonder if the figures that do deepcopy couldn't call another fixture that has module level like https://github.com/braindecode/braindecode/blob/master/test/unit_tests/samplers/test_samplers.py#L22-L34?
Seems nicer to me to not have code that executes on import
what do you mean it's execute on import? it should executed when you start pytest
I mean in this code, the dataset and window creation is done on module level, so when test_preprocess.py is imported it would be executed: https://github.com/braindecode/braindecode/blob/e7063545e7462fb50e216d7cd31020b36ae4d521/test/unit_tests/datautil/test_preprocess.py#L18-L26
Don't know if this really causes any problems, but seems slightly unclean? like this may not be the way pytest expects as well?
We could instantiate the objects in session-level fixtures, and have function-level fixtures that do the deepcopy like here: https://stackoverflow.com/questions/53193932/how-to-avoid-mutating-objects-from-session-scope-fixtures-in-pytest