Solution
def test_authenticate():
with flask.Flask(__name__).test_request_context() as flask_context:
flask_context.request.headers = {"by-pass": "internal-bypass-key"}
@auth.Auth.authenticate
def test_func(*args, **kwargs):
return "hello"
assert test_func(2, 3, 4, multiplier=2) == "hello"
assert flask_context.g.user == "by_pass"