-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
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.