Skip unit tests which require optional dependencies (#9031)

If we are lacking an optional dependency, skip the tests that rely on it.
This commit is contained in:
Richard van der Hoff 2021-01-07 11:41:28 +00:00 committed by GitHub
parent eee3c3c52f
commit 8d3d264052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 14 deletions

View file

@ -20,8 +20,16 @@ from synapse.rest.media.v1.preview_url_resource import (
from . import unittest
try:
import lxml
except ImportError:
lxml = None
class PreviewTestCase(unittest.TestCase):
if not lxml:
skip = "url preview feature requires lxml"
def test_long_summarize(self):
example_paras = [
"""Tromsø (Norwegian pronunciation: [ˈtrʊmsœ] ( listen); Northern Sami:
@ -137,6 +145,9 @@ class PreviewTestCase(unittest.TestCase):
class PreviewUrlTestCase(unittest.TestCase):
if not lxml:
skip = "url preview feature requires lxml"
def test_simple(self):
html = """
<html>