mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-11 22:24:18 -05:00
Use mock from standard library (#11588)
Instead of the backported version.
This commit is contained in:
parent
8ad39438fa
commit
7a7ca8f226
1
changelog.d/11588.removal
Normal file
1
changelog.d/11588.removal
Normal file
@ -0,0 +1 @@
|
|||||||
|
Replace `mock` package by its standard library version.
|
4
setup.py
4
setup.py
@ -120,9 +120,7 @@ CONDITIONAL_REQUIREMENTS["mypy"] = [
|
|||||||
# Tests assume that all optional dependencies are installed.
|
# Tests assume that all optional dependencies are installed.
|
||||||
#
|
#
|
||||||
# parameterized_class decorator was introduced in parameterized 0.7.0
|
# parameterized_class decorator was introduced in parameterized 0.7.0
|
||||||
#
|
CONDITIONAL_REQUIREMENTS["test"] = ["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["dev"] = (
|
CONDITIONAL_REQUIREMENTS["dev"] = (
|
||||||
CONDITIONAL_REQUIREMENTS["lint"]
|
CONDITIONAL_REQUIREMENTS["lint"]
|
||||||
|
@ -12,15 +12,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# Use backported mock for AsyncMock support on Python 3.6.
|
from unittest.mock import Mock
|
||||||
from mock import Mock
|
|
||||||
|
|
||||||
from twisted.internet.defer import Deferred, ensureDeferred
|
from twisted.internet.defer import Deferred, ensureDeferred
|
||||||
|
|
||||||
from synapse.storage.background_updates import BackgroundUpdater
|
from synapse.storage.background_updates import BackgroundUpdater
|
||||||
|
|
||||||
from tests import unittest
|
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):
|
class BackgroundUpdateTestCase(unittest.HomeserverTestCase):
|
||||||
@ -116,14 +115,14 @@ class BackgroundUpdateControllerTestCase(unittest.HomeserverTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Mock out the AsyncContextManager
|
# Mock out the AsyncContextManager
|
||||||
self._update_ctx_manager = Mock(spec=["__aenter__", "__aexit__"])
|
class MockCM:
|
||||||
self._update_ctx_manager.__aenter__ = Mock(
|
__aenter__ = simple_async_mock(return_value=None)
|
||||||
return_value=make_awaitable(None),
|
__aexit__ = simple_async_mock(return_value=None)
|
||||||
)
|
|
||||||
self._update_ctx_manager.__aexit__ = Mock(return_value=make_awaitable(None))
|
self._update_ctx_manager = MockCM
|
||||||
|
|
||||||
# Mock out the `update_handler` callback
|
# 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
|
# Define a default batch size value that's not the same as the internal default
|
||||||
# value (100).
|
# value (100).
|
||||||
|
Loading…
Reference in New Issue
Block a user