This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Rob Taft
Recipients Rob Taft
Date 2020-05-28.12:19:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590668397.14.0.891806096405.issue40805@roundup.psfhosted.org>
In-reply-to
Content
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()
History
Date User Action Args
2020-05-28 12:19:57Rob Taftsetrecipients: + Rob Taft
2020-05-28 12:19:57Rob Taftsetmessageid: <1590668397.14.0.891806096405.issue40805@roundup.psfhosted.org>
2020-05-28 12:19:57Rob Taftlinkissue40805 messages
2020-05-28 12:19:56Rob Taftcreate