@@ -743,14 +743,14 @@ exception is raised in the setUp then tearDown is not called.
743743Mocking Unbound Methods
744744~~~~~~~~~~~~~~~~~~~~~~~
745745
746- Sometimes a test needs to patch an *unbound method * which means patching the
747- method on the class rather than on the instance. In order to make asserts
748- about which objects were calling this particular method, you need to pass
749- self as the first argument. The issue is that you can't patch with a mock for
746+ Sometimes a test needs to patch an *unbound method *, which means patching the
747+ method on the class rather than on the instance. In order to make assertions
748+ about which objects were calling this particular method, you need to pass
749+ `` self `` as the first argument. The issue is that you can't patch with a mock for
750750this, because if you replace an unbound method with a mock it doesn't become
751- a bound method when fetched from the instance, and so it doesn't get self
751+ a bound method when fetched from the instance, and so it doesn't get `` self ``
752752passed in. The workaround is to patch the unbound method with a real function
753- instead. The :func: `patch ` decorator makes it so simple to patch out methods
753+ instead. The :func: `patch ` decorator makes it so simple to patch out methods
754754with a mock that having to create a real function becomes a nuisance.
755755
756756If you pass ``autospec=True `` to patch then it does the patching with a
@@ -759,7 +759,7 @@ it is replacing, but delegates to a mock under the hood. You still get your
759759mock auto-created in exactly the same way as before. What it means though, is
760760that if you use it to patch out an unbound method on a class the mocked
761761function will be turned into a bound method if it is fetched from an instance.
762- It will have ``self `` passed in as the first argument, which is exactly what
762+ It will have ``self `` passed in as the first argument, which is exactly what
763763was needed:
764764
765765 >>> class Foo :
0 commit comments