コード例 #1
0
ファイル: test_specifiers.py プロジェクト: nvie/packaging
    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))
コード例 #2
0
ファイル: main.py プロジェクト: svrana/pipsqueak
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
コード例 #3
0
    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
コード例 #4
0
    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))
コード例 #5
0
    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
コード例 #6
0
 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)