]> granicus.if.org Git - python/commitdiff
Issue #26688: Fix module name in mock docs
authorBerker Peksag <berker.peksag@gmail.com>
Sat, 2 Apr 2016 01:32:06 +0000 (04:32 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Sat, 2 Apr 2016 01:32:06 +0000 (04:32 +0300)
Patch by Ashley Anderson.

Doc/library/unittest.mock-examples.rst

index ac7fce032351f96e9d727371f2fc336e751b8a5c..0bb52ef23082a8a8750e9bfb1a0933411d82eb78 100644 (file)
@@ -359,7 +359,7 @@ The module name can be 'dotted', in the form ``package.module`` if needed:
 
 A nice pattern is to actually decorate test methods themselves:
 
-    >>> class MyTest(unittest2.TestCase):
+    >>> class MyTest(unittest.TestCase):
     ...     @patch.object(SomeClass, 'attribute', sentinel.attribute)
     ...     def test_something(self):
     ...         self.assertEqual(SomeClass.attribute, sentinel.attribute)
@@ -372,7 +372,7 @@ If you want to patch with a Mock, you can use :func:`patch` with only one argume
 (or :func:`patch.object` with two arguments). The mock will be created for you and
 passed into the test function / method:
 
-    >>> class MyTest(unittest2.TestCase):
+    >>> class MyTest(unittest.TestCase):
     ...     @patch.object(SomeClass, 'static_method')
     ...     def test_something(self, mock_method):
     ...         SomeClass.static_method()
@@ -382,7 +382,7 @@ passed into the test function / method:
 
 You can stack up multiple patch decorators using this pattern:
 
-    >>> class MyTest(unittest2.TestCase):
+    >>> class MyTest(unittest.TestCase):
     ...     @patch('package.module.ClassName1')
     ...     @patch('package.module.ClassName2')
     ...     def test_something(self, MockClass2, MockClass1):