Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b31daff1
Commit
b31daff1
authored
Apr 02, 2016
by
Berker Peksag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26688: Fix module name in mock docs
Patch by Ashley Anderson.
parent
16c7cfda
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
Doc/library/unittest.mock-examples.rst
Doc/library/unittest.mock-examples.rst
+3
-3
No files found.
Doc/library/unittest.mock-examples.rst
View file @
b31daff1
...
...
@@ -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(unittest
2
.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(unittest
2
.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(unittest
2
.TestCase):
>>> class MyTest(unittest.TestCase):
... @patch('package.module.ClassName1')
... @patch('package.module.ClassName2')
... def test_something(self, MockClass2, MockClass1):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment