diff --git a/tests/rest/client/test_media.py b/tests/rest/client/test_media.py index e14e01cb7a3..a20fe698eed 100644 --- a/tests/rest/client/test_media.py +++ b/tests/rest/client/test_media.py @@ -47,6 +47,11 @@ from tests.test_utils import SMALL_PNG from tests.unittest import override_config +try: + import lxml +except ImportError: + lxml = None # type: ignore[assignment] + class UnstableMediaDomainBlockingTests(unittest.HomeserverTestCase): remote_media_id = "doesnotmatter" @@ -163,10 +168,6 @@ def test_remote_media_thumbnail_normally_unblocked(self) -> None: class UnstableURLPreviewTests(unittest.HomeserverTestCase): - try: - import lxml - except ImportError: - lxml = None # type: ignore[assignment] if not lxml: skip = "url preview feature requires lxml"