[pytest-dev] PEP420, Namespace Packages and Pytest Test Layout
Floris Bruynooghe
flub at devork.be
Thu Aug 2 17:40:33 EDT 2018
Hi Alexandre,
On Thu 02 Aug 2018 at 16:45 +0200, Alexandre Figura wrote:
> I recently discovered that it was possible to import test modules from
> other test modules without having __init__.py files in my test
> directories. I thought it was impossible to do so with Pytest. And
> discovered it was possible because of the PEP420 and namespace
> packages
> <https://docs.pytest.org/en/latest/goodpractices.html?highlight=pep420#tests-as-part-of-application-code>.
>
> However, I am wondering now if I should rely on the PEP420 to import
> test modules. I mean, is Pytest designed to be used in this way? Or
> should I avoid to rely on Python 3 behavior, and use a more "Pytestic"
> way of structuring my test modules?
Sure, there's nothing wrong with using PEP420 namespace packages in your
test modules layout. All the advice which uses __init__.py is probably
just because it's old I think (or to be compatible with 2.7 which is
still supported).
Cheers,
Floris
More information about the pytest-dev
mailing list