[New-bugs-announce] [issue40805] Can no longer patch flask.g

Rob Taft report at bugs.python.org
Thu May 28 08:19:57 EDT 2020


New submission from Rob Taft <rrtaft at gmail.com>:

Whenever I try to patch flask.g, it appears to do nothing.  This happened when I upgraded mock from 3.x to 4.x.  I reported it on the mock github page https://github.com/testing-cabal/mock/issues/490 and was asked to report it here.  The folllowing code run with pytest works fine in mock 3.0.5, but fails to patch in 4.0.0 and up.

from mock import patch

import flask


def some_function():
    flask.g.somevariable = True
    return flask.g.somevariable


@patch('flask.g')
def test_some_function(mock_flask_global):
    assert some_function()

----------
components: Tests
messages: 370197
nosy: Rob Taft
priority: normal
severity: normal
status: open
title: Can no longer patch flask.g
type: behavior
versions: Python 3.6, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40805>
_______________________________________


More information about the New-bugs-announce mailing list