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
30ffe7eb
Commit
30ffe7eb
authored
Jan 21, 2014
by
Terry Jan Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20222: file is no longer a builtin in 3.x.
parent
39d798eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
Doc/library/unittest.mock-examples.rst
Doc/library/unittest.mock-examples.rst
+2
-2
No files found.
Doc/library/unittest.mock-examples.rst
View file @
30ffe7eb
...
@@ -462,7 +462,7 @@ the `backend` attribute on a `Something` instance. In this particular case
...
@@ -462,7 +462,7 @@ the `backend` attribute on a `Something` instance. In this particular case
we are only interested in the return value from the final call to
we are only interested in the return value from the final call to
`start_call` so we don't have much configuration to do. Let's assume the
`start_call` so we don't have much configuration to do. Let's assume the
object it returns is 'file-like', so we'll ensure that our response object
object it returns is 'file-like', so we'll ensure that our response object
uses the builtin `
file
` as its `spec`.
uses the builtin `
open
` as its `spec`.
To do this we create a mock instance as our mock backend and create a mock
To do this we create a mock instance as our mock backend and create a mock
response object for it. To set the response as the return value for that final
response object for it. To set the response as the return value for that final
...
@@ -474,7 +474,7 @@ We can do that in a slightly nicer way using the :meth:`~Mock.configure_mock`
...
@@ -474,7 +474,7 @@ We can do that in a slightly nicer way using the :meth:`~Mock.configure_mock`
method to directly set the return value for us:
method to directly set the return value for us:
>>> something = Something()
>>> something = Something()
>>> mock_response = Mock(spec=
file
)
>>> mock_response = Mock(spec=
open
)
>>> mock_backend = Mock()
>>> mock_backend = Mock()
>>> config = {'get_endpoint.return_value.create_call.return_value.start_call.return_value': mock_response}
>>> config = {'get_endpoint.return_value.create_call.return_value.start_call.return_value': mock_response}
>>> mock_backend.configure_mock(**config)
>>> mock_backend.configure_mock(**config)
...
...
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