diff options
author | David Robertson <davidr@element.io> | 2022-03-18 19:03:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-18 19:03:46 +0000 |
commit | bf9d549e3ad944e1e53a2ecc898640d690bf1eac (patch) | |
tree | a98ba90de14f198c62d58eaf1323ac7372f0e524 /tests/util/test_check_dependencies.py | |
parent | Move get_bundled_aggregations to relations handler. (#12237) (diff) | |
download | synapse-bf9d549e3ad944e1e53a2ecc898640d690bf1eac.tar.xz |
Try to detect borked package installations. (#12244)
* Try to detect borked package installations. Fixes #12223. Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Diffstat (limited to 'tests/util/test_check_dependencies.py')
-rw-r--r-- | tests/util/test_check_dependencies.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/util/test_check_dependencies.py b/tests/util/test_check_dependencies.py index 38e9f58ac6..5d1aa025d1 100644 --- a/tests/util/test_check_dependencies.py +++ b/tests/util/test_check_dependencies.py @@ -12,7 +12,7 @@ from tests.unittest import TestCase class DummyDistribution(metadata.Distribution): - def __init__(self, version: str): + def __init__(self, version: object): self._version = version @property @@ -30,6 +30,7 @@ old = DummyDistribution("0.1.2") old_release_candidate = DummyDistribution("0.1.2rc3") new = DummyDistribution("1.2.3") new_release_candidate = DummyDistribution("1.2.3rc4") +distribution_with_no_version = DummyDistribution(None) # could probably use stdlib TestCase --- no need for twisted here @@ -67,6 +68,18 @@ class TestDependencyChecker(TestCase): # should not raise check_requirements() + def test_version_reported_as_none(self) -> None: + """Complain if importlib.metadata.version() returns None. + + This shouldn't normally happen, but it was seen in the wild (#12223). + """ + with patch( + "synapse.util.check_dependencies.metadata.requires", + return_value=["dummypkg >= 1"], + ): + with self.mock_installed_package(distribution_with_no_version): + self.assertRaises(DependencyException, check_requirements) + def test_checks_ignore_dev_dependencies(self) -> None: """Bot generic and per-extra checks should ignore dev dependencies.""" with patch( |