def test_specifiers(self, version, spec, expected): spec = LegacySpecifier(spec, prereleases=True) if expected: # Test that the plain string form works assert spec.contains(version) # Test that the version instance form works assert spec.contains(LegacyVersion(version)) else: # Test that the plain string form works assert not spec.contains(version) # Test that the version instance form works assert not spec.contains(LegacyVersion(version))
def _versions_match(required, installed): if required is None: return True try: req = Specifier(required) except InvalidSpecifier: req = LegacySpecifier(required) contains = req.contains(installed[2:]) return contains
def test_specifier_explicit_prereleases(self): spec = LegacySpecifier(">=1.0") assert not spec.prereleases spec.prereleases = True assert spec.prereleases spec = LegacySpecifier(">=1.0", prereleases=False) assert not spec.prereleases spec.prereleases = True assert spec.prereleases spec = LegacySpecifier(">=1.0", prereleases=True) assert spec.prereleases spec.prereleases = False assert not spec.prereleases spec = LegacySpecifier(">=1.0", prereleases=True) assert spec.prereleases spec.prereleases = None assert not spec.prereleases
def test_legacy_specifier_is_deprecated(self): with warnings.catch_warnings(record=True) as w: LegacySpecifier(">=some-legacy-version") assert len(w) == 1 assert issubclass(w[0].category, DeprecationWarning)