Skip to content

Rewrite hook attempts to rewrite namespace package #2419

@jaraco

Description

@jaraco

As discovered in pypa/setuptools#1038, when the following is true:

  • a plugin (such as backports.unittest_mock) is a namespace package,
  • that namespace package is defined using the recommended pkg_util technique,
  • that plugin is used by the test environment, and
  • something in the test suite attempts to import another package in that namespace,

py.test will attempt to rewrite the namespace package module, which will cause errors in sandboxed environments where writing outside of the prescribed directory is disallowed.

It's not obvious to me that this is a bug in pytest, and I admit, the factors are highly specialized.

Still, since namespace packages using the pkg_resources technique don't cause pytest to rewrite that package, I'd like to consider if this issue can be addressed by pytest detecting and honoring these namespace packages and excluding them from needing rewriting.

I have a minimal test project I will be pushing shortly demonstrating the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanismtype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions