@@ -40,7 +40,10 @@ class TestDependencyChecker(TestCase):
40
40
def mock_installed_package (
41
41
self , distribution : Optional [DummyDistribution ]
42
42
) -> Generator [None , None , None ]:
43
- """Pretend that looking up any distribution yields the given `distribution`."""
43
+ """Pretend that looking up any package yields the given `distribution`.
44
+
45
+ If `distribution = None`, we pretend that the package is not installed.
46
+ """
44
47
45
48
def mock_distribution (name : str ):
46
49
if distribution is None :
@@ -81,7 +84,7 @@ def test_version_reported_as_none(self) -> None:
81
84
self .assertRaises (DependencyException , check_requirements )
82
85
83
86
def test_checks_ignore_dev_dependencies (self ) -> None :
84
- """Bot generic and per-extra checks should ignore dev dependencies."""
87
+ """Both generic and per-extra checks should ignore dev dependencies."""
85
88
with patch (
86
89
"synapse.util.check_dependencies.metadata.requires" ,
87
90
return_value = ["dummypkg >= 1; extra == 'mypy'" ],
@@ -142,3 +145,16 @@ def test_release_candidates_satisfy_dependency(self) -> None:
142
145
with self .mock_installed_package (new_release_candidate ):
143
146
# should not raise
144
147
check_requirements ()
148
+
149
+ def test_setuptools_rust_ignored (self ) -> None :
150
+ """Test a workaround for a `poetry build` problem. Reproduces #13926."""
151
+ with patch (
152
+ "synapse.util.check_dependencies.metadata.requires" ,
153
+ return_value = ["setuptools_rust >= 1.3" ],
154
+ ):
155
+ with self .mock_installed_package (None ):
156
+ # should not raise, even if setuptools_rust is not installed
157
+ check_requirements ()
158
+ with self .mock_installed_package (old ):
159
+ # We also ignore old versions of setuptools_rust
160
+ check_requirements ()
0 commit comments