Skip to content

pytest blows up when collecting modules with uninspectable objects #214

@pytestbot

Description

@pytestbot

Originally reported by: Thomas Waldmann (BitBucket: thomaswaldmann, GitHub: thomaswaldmann)


werkzeug/flask offers some threadlocals to comfortable access stuff like (http) request, session, (wsgi) app, etc. - those objects are special and only valid when a request is running or an app was created.

if you access them before / after they are valid, it'll raise a RuntimeError.

while collecting tests, pytest (since 2.3) accesses all module-level objects and tries to inspect them for a specific attribute, causing a RuntimeError exception when it does that on such special objects.

thus, the usual code used in about every flask app makes pytest unusable:

from flask import request, session # <- threadlocals

a simple patch that solves the issue is attached.


Metadata

Metadata

Assignees

No one assigned

    Labels

    type: 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