I got a problem when I tried to test a flask app that I can not access the g
variable.
The api which is gonna tested looks like this:
user = query_object.get(g.user_id) # here the exception raises
When I run the test, it raises:
NameError: global name 'g' is not defined
What are your imports? You should try and add
from flask import g
Or, if you're using Quart
from quart import g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With