Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
7a7ca8f2
Unverified
Commit
7a7ca8f2
authored
3 years ago
by
V02460
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use mock from standard library (#11588)
Instead of the backported version.
parent
8ad39438
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/11588.removal
+1
-0
1 addition, 0 deletions
changelog.d/11588.removal
setup.py
+1
-3
1 addition, 3 deletions
setup.py
tests/storage/test_background_update.py
+8
-9
8 additions, 9 deletions
tests/storage/test_background_update.py
with
10 additions
and
12 deletions
changelog.d/11588.removal
0 → 100644
+
1
−
0
View file @
7a7ca8f2
Replace `mock` package by its standard library version.
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
3
View file @
7a7ca8f2
...
...
@@ -120,9 +120,7 @@ CONDITIONAL_REQUIREMENTS["mypy"] = [
# Tests assume that all optional dependencies are installed.
#
# parameterized_class decorator was introduced in parameterized 0.7.0
#
# We use `mock` library as that backports `AsyncMock` to Python 3.6
CONDITIONAL_REQUIREMENTS
[
"
test
"
]
=
[
"
parameterized>=0.7.0
"
,
"
mock>=4.0.0
"
]
CONDITIONAL_REQUIREMENTS
[
"
test
"
]
=
[
"
parameterized>=0.7.0
"
]
CONDITIONAL_REQUIREMENTS
[
"
dev
"
]
=
(
CONDITIONAL_REQUIREMENTS
[
"
lint
"
]
...
...
This diff is collapsed.
Click to expand it.
tests/storage/test_background_update.py
+
8
−
9
View file @
7a7ca8f2
...
...
@@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Use backported mock for AsyncMock support on Python 3.6.
from
mock
import
Mock
from
unittest.mock
import
Mock
from
twisted.internet.defer
import
Deferred
,
ensureDeferred
from
synapse.storage.background_updates
import
BackgroundUpdater
from
tests
import
unittest
from
tests.test_utils
import
make_awaitable
from
tests.test_utils
import
make_awaitable
,
simple_async_mock
class
BackgroundUpdateTestCase
(
unittest
.
HomeserverTestCase
):
...
...
@@ -116,14 +115,14 @@ class BackgroundUpdateControllerTestCase(unittest.HomeserverTestCase):
)
# Mock out the AsyncContextManager
self
.
_update_ctx_manager
=
Mock
(
spec
=
[
"
__aenter__
"
,
"
__aexit__
"
])
self
.
_update_ctx_manager
.
__aenter__
=
Mock
(
return_value
=
make_awaitable
(
None
)
,
)
self
.
_update_ctx_manager
.
__aexit__
=
Mock
(
return_value
=
make_awaitable
(
None
))
class
MockCM
:
__aenter__
=
simple_async_mock
(
return_value
=
None
)
__aexit__
=
simple_async_mock
(
return_value
=
None
)
self
.
_update_ctx_manager
=
MockCM
# Mock out the `update_handler` callback
self
.
_on_update
=
Mock
(
return_value
=
self
.
_update_ctx_manager
)
self
.
_on_update
=
Mock
(
return_value
=
self
.
_update_ctx_manager
()
)
# Define a default batch size value that's not the same as the internal default
# value (100).
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment