Skip to content

pytest fails with implicit namespaces #5590

Closed
@aatkinson

Description

@aatkinson

Pytest doesn't seem to work with implicit namespaces in your source, as defined by PEP 420. This still occurs as of pytest 5.0.1 installed in a Python 3 environment.

Note this is for the source package being tested, and I've encountered the issue with tests outside of the source package (init.py files are required for tests as noted in the best practices document.

E.g.

mypkg/
    foo/
        baz.py
    bar/
        baz.py
tests/

will yield errors like

./../../.local/lib/python3.6/site-packages/py/_path/local.py:721: in pyimport
    raise self.ImportMismatchError(modname, modfile, self)
E   py._path.local.LocalPath.ImportMismatchError: ('baz', '/home/vsts/work/1/s/mkpkg/foo/baz.py', local('/home/vsts/work/1/s/mkpkg/bar/mkpkg.py'))

This issue has appeared in #774.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions