summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2012-03-25 02:00:31 +0100
committerMichael Foord <michael@voidspace.org.uk>2012-03-25 02:00:31 +0100
commit92949250a4dc7870607a078bd8d7ebf60dc7fb48 (patch)
tree02b66e39a04b394d071fc9310fcdbee931143f5f /tests
parent0687038f1a8761af2393199ccb012f7341e24d43 (diff)
downloadmock-92949250a4dc7870607a078bd8d7ebf60dc7fb48.tar.gz
Make using create=True with spec=True in patchers an error
Diffstat (limited to 'tests')
-rw-r--r--tests/testpatch.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/testpatch.py b/tests/testpatch.py
index 54d3878..d6ebec3 100644
--- a/tests/testpatch.py
+++ b/tests/testpatch.py
@@ -1682,6 +1682,21 @@ class PatchTest(unittest2.TestCase):
'exception traceback not propgated')
+ def test_create_and_specs(self):
+ for kwarg in ('spec', 'spec_set', 'autospec'):
+ p = patch('%s.doesnotexist' % __name__, create=True,
+ **{kwarg: True})
+ self.assertRaises(TypeError, p.start)
+ self.assertRaises(NameError, lambda: doesnotexist)
+
+ # check that spec with create is innocuous if the original exists
+ p = patch('%s.PTModule' % __name__, create=True,
+ **{kwarg: True})
+ try:
+ p.start()
+ finally:
+ p.stop()
+
if __name__ == '__main__':
unittest2.main()