New submission from Rob Taft <rrt...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue40805>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to