Up to now I use this pattern for my python files containing the tests:
setup.py mylib/views/foo.py mylib/tests/views/test_foo.py
After reading about the LoB Principle (The behaviour of a code unit should be as obvious as possible by looking only at that unit of code) I think
it might make more sense to use this pattern:
If you do it extreme, then you could put the test code into the production code, but this would bloat the memory, so I think a different file makes sense. But keeping it close to the original makes switching between production code and test code easier.
At least the pytest documentation does not consider this layout: Good Integration Practices — pytest documentation
What do you think?