From 3d60f955f037e53a4be0a6561d664b8cb43367a9 Mon Sep 17 00:00:00 2001 From: feuillemorte Date: Tue, 10 Apr 2018 20:18:05 +0300 Subject: [PATCH] #3290 Added test --- testing/test_monkeypatch.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 4427908ab..b524df89b 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -327,3 +327,16 @@ def test_issue1338_name_resolving(): monkeypatch.delattr('requests.sessions.Session.request') finally: monkeypatch.undo() + + +def test_context(testdir): + testdir.makepyfile(""" + import functools + def test_partial(monkeypatch): + with monkeypatch.context() as m: + m.setattr(functools, "partial", 3) + assert functools.partial == 3 + """) + + result = testdir.runpytest() + result.stdout.fnmatch_lines("*1 passed*")