Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b31daff

Browse files
committed
Issue #26688: Fix module name in mock docs
Patch by Ashley Anderson.
1 parent 16c7cfd commit b31daff

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Doc/library/unittest.mock-examples.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ The module name can be 'dotted', in the form ``package.module`` if needed:
359359

360360
A nice pattern is to actually decorate test methods themselves:
361361

362-
>>> class MyTest(unittest2.TestCase):
362+
>>> class MyTest(unittest.TestCase):
363363
... @patch.object(SomeClass, 'attribute', sentinel.attribute)
364364
... def test_something(self):
365365
... 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
372372
(or :func:`patch.object` with two arguments). The mock will be created for you and
373373
passed into the test function / method:
374374

375-
>>> class MyTest(unittest2.TestCase):
375+
>>> class MyTest(unittest.TestCase):
376376
... @patch.object(SomeClass, 'static_method')
377377
... def test_something(self, mock_method):
378378
... SomeClass.static_method()
@@ -382,7 +382,7 @@ passed into the test function / method:
382382

383383
You can stack up multiple patch decorators using this pattern:
384384

385-
>>> class MyTest(unittest2.TestCase):
385+
>>> class MyTest(unittest.TestCase):
386386
... @patch('package.module.ClassName1')
387387
... @patch('package.module.ClassName2')
388388
... def test_something(self, MockClass2, MockClass1):

0 commit comments

Comments
 (0)