Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

alkaline-ml / importlib-metadata   python

Repository URL to install this package:

Version: 1.3.0 

/ tests / test_integration.py

import unittest
import packaging.requirements
import packaging.version

from . import fixtures
from .. import version


class IntegrationTests(fixtures.DistInfoPkg, unittest.TestCase):

    def test_package_spec_installed(self):
        """
        Illustrate the recommended procedure to determine if
        a specified version of a package is installed.
        """
        def is_installed(package_spec):
            req = packaging.requirements.Requirement(package_spec)
            return version(req.name) in req.specifier

        assert is_installed('distinfo-pkg==1.0')
        assert is_installed('distinfo-pkg>=1.0,<2.0')
        assert not is_installed('distinfo-pkg<1.0')