summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2014-04-15 21:22:22 (GMT)
committerMichael Foord <michael@voidspace.org.uk>2014-04-15 21:22:22 (GMT)
commit15f2d1775e64b3ae0742f0faae108bc3d6e3d5e4 (patch)
tree67a93e8c6553d0d8d3153fdf657cb72194d4305d /Lib/unittest/test
parent27adf4469023597883d9240ad40a7a52d81b6f66 (diff)
parentebc1a30d55f07d590d62504c3f097cb8a15ee7d3 (diff)
downloadcpython-15f2d1775e64b3ae0742f0faae108bc3d6e3d5e4.zip
cpython-15f2d1775e64b3ae0742f0faae108bc3d6e3d5e4.tar.gz
cpython-15f2d1775e64b3ae0742f0faae108bc3d6e3d5e4.tar.bz2
Merge
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/testmock/testpatch.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/unittest/test/testmock/testpatch.py
index d941d8a..28fe86b 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/unittest/test/testmock/testpatch.py
@@ -12,7 +12,7 @@ from unittest.test.testmock.support import SomeClass, is_instance
from unittest.mock import (
NonCallableMock, CallableMixin, patch, sentinel,
MagicMock, Mock, NonCallableMagicMock, patch, _patch,
- DEFAULT, call, _get_target
+ DEFAULT, call, _get_target, _patch
)
@@ -1799,6 +1799,23 @@ class PatchTest(unittest.TestCase):
patched()
self.assertIs(os.path, path)
+ def test_stopall_lifo(self):
+ stopped = []
+ class thing(object):
+ one = two = three = None
+
+ def get_patch(attribute):
+ class mypatch(_patch):
+ def stop(self):
+ stopped.append(attribute)
+ return super(mypatch, self).stop()
+ return mypatch(lambda: thing, attribute, None, None,
+ False, None, None, None, {})
+ [get_patch(val).start() for val in ("one", "two", "three")]
+ patch.stopall()
+
+ self.assertEqual(stopped, ["three", "two", "one"])
+
if __name__ == '__main__':
unittest.main()