Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Refactor user directory tests #10935

Merged
merged 8 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/handlers/test_user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from urllib.parse import quote

from twisted.internet import defer
from twisted.internet.testing import MemoryReactor

import synapse.rest.admin
from synapse.api.constants import UserTypes
Expand All @@ -28,6 +27,7 @@

from tests import unittest
from tests.storage.test_user_directory import GetUserDirectoryTables
from tests.types import MemoryReactor
from tests.unittest import override_config


Expand Down
3 changes: 1 addition & 2 deletions tests/storage/test_user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
# limitations under the License.
from typing import Dict, List, Set, Tuple

from twisted.internet.testing import MemoryReactor

from synapse.rest import admin
from synapse.rest.client import login, room
from synapse.server import HomeServer
from synapse.storage import DataStore
from synapse.util import Clock

from tests.types import MemoryReactor
from tests.unittest import HomeserverTestCase, override_config

ALICE = "@alice:a"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_terms_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
import json
from unittest.mock import Mock

from twisted.test.proto_helpers import MemoryReactorClock

from synapse.rest.client.register import register_servlets
from synapse.util import Clock

from tests import unittest
from tests.types import MemoryReactorClock


class TermsTestCase(unittest.HomeserverTestCase):
Expand Down
9 changes: 9 additions & 0 deletions tests/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
try:
from twisted.internet.testing import MemoryReactor, MemoryReactorClock
except ImportError:
# Twisted 19.7 moved stuff from twisted.test.proto_helpers to
# twisted.internet.testing. Let's do the import once rather than doing it
# in lots of different files.
from twisted.test.proto_helpers import MemoryReactor, MemoryReactorClock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given it's still available in twisted.test.proto_helpers in current twisted, why not just import it from there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was leaning towards "make it obvious what the deprecated thing is". No strong opinions though, and we have your CI change to detect any twisted trunk breakages. I'll make that change quickly now.


__all__ = ["MemoryReactor", "MemoryReactorClock"]
2 changes: 1 addition & 1 deletion tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from canonicaljson import json

from twisted.internet.defer import Deferred, ensureDeferred, succeed
from twisted.internet.testing import MemoryReactor
from twisted.python.failure import Failure
from twisted.python.threadpool import ThreadPool
from twisted.trial import unittest
Expand Down Expand Up @@ -54,6 +53,7 @@
from tests.server import FakeChannel, get_clock, make_request, setup_test_homeserver
from tests.test_utils import event_injection, setup_awaitable_errors
from tests.test_utils.logging_setup import setup_logging
from tests.types import MemoryReactor
from tests.utils import default_config, setupdb

setupdb()
Expand Down