def test_normalize_python_package_name(self):
        """Test normalize python package name."""
        package_version = PackageVersion(name="Cython", version="0.29.13", develop=False)
        assert package_version.name == "cython"

        package_version = PackageVersion(name="semantic_version", version="2.6.0", develop=False)
        assert package_version.name == "semantic-version"

        package_version = PackageVersion(name="delegator.py", version="0.1.1", develop=False)
        assert package_version.name == "delegator-py"
    def test_normalize_python_package_version(self):
        """Test normalize python package version."""
        package_version = PackageVersion(name="oauth2client", version="1.0beta2", develop=False)
        assert package_version.version == "1.0b2"

        package_version = PackageVersion(name="regex", version="2019.02.06", develop=False)
        assert package_version.version == "2019.2.6"

        package_version = PackageVersion(name="xgboost", version="0.7.post2", develop=False)
        assert package_version.version == "0.7.post2"

        package_version = PackageVersion(name="xgboost", version="0.71", develop=False)
        assert package_version.version == "0.71"

        package_version = PackageVersion(name="ipywidgets", version="6.0.0.rc3", develop=False)
        assert package_version.version == "6.0.0rc3"

        package_version = PackageVersion(name="pytz", version="2011b", develop=False)
        assert package_version.version == "2011b0"

        package_version = PackageVersion(name="gitpython", version="0.3.2.RC1", develop=False)
        assert package_version.version == "0.3.2rc1"

        package_version = PackageVersion(name="ipywidgets", version="5.0.0.b5", develop=False)
        assert package_version.version == "5.0.0b5"
Ejemplo n.º 3
0
    def test_normalize_python_package_name(self):
        package_version = PackageVersion(name='Cython',
                                         version='0.29.13',
                                         develop=False)
        assert package_version.name == "cython"

        package_version = PackageVersion(name='semantic_version',
                                         version='2.6.0',
                                         develop=False)
        assert package_version.name == "semantic-version"

        package_version = PackageVersion(name='delegator.py',
                                         version='0.1.1',
                                         develop=False)
        assert package_version.name == "delegator-py"
    def test_sorted(self):
        """Test sorted."""
        array = []
        for version in ("==1.0.0", "==0.1.0", "==3.0.0"):
            array.append(PackageVersion(name="tensorflow", version=version, develop=False))

        assert sorted(pv.locked_version for pv in array) == ["0.1.0", "1.0.0", "3.0.0"]
 def test_parse_semver_leading_zeros(self):
     """Test parse semver leading zeros."""
     package_version = PackageVersion(
         name="pyyaml", version="==3.01.2", index="https://pypi.org/simple", develop=False
     )
     assert package_version.semantic_version.release[0] == 3
     assert package_version.semantic_version.release[1] == 1
     assert package_version.semantic_version.release[2] == 2
 def test_parse_semver(self):
     """Test parse semver."""
     package_version = PackageVersion(
         name="tensorflow", version="==1.9.0", index="https://pypi.org/simple", develop=False
     )
     assert package_version.semantic_version.release[0] == 1
     assert package_version.semantic_version.release[1] == 9
     assert package_version.semantic_version.release[2] == 0
Ejemplo n.º 7
0
    def test_version_specification(self):
        pv = PackageVersion(name='tensorflow',
                            version='==0.1.0',
                            develop=False).semantic_version
        vs = PackageVersion(name='tensorflow', version='<1.0.0',
                            develop=False).version_specification
        assert pv in vs

        pv = PackageVersion(name='tensorflow',
                            version='==2.1.0',
                            develop=False).semantic_version
        assert pv not in vs

        vs = PackageVersion(name='tensorflow',
                            version='==2.1.0',
                            develop=False).version_specification
        assert pv in vs
Ejemplo n.º 8
0
 def test_parse_semver_leading_zeros(self):
     package_version = PackageVersion(name="pyyaml",
                                      version="==3.01.2",
                                      index="https://pypi.org/simple",
                                      develop=False)
     assert package_version.semantic_version.major == 3
     assert package_version.semantic_version.minor == 1
     assert package_version.semantic_version.patch == 2
Ejemplo n.º 9
0
 def test_parse_semver(self):
     package_version = PackageVersion(name="tensorflow",
                                      version="==1.9.0",
                                      index="https://pypi.org/simple",
                                      develop=False)
     assert package_version.semantic_version.major == 1
     assert package_version.semantic_version.minor == 9
     assert package_version.semantic_version.patch == 0
Ejemplo n.º 10
0
    def test_sorted(self):
        array = []
        for version in ('==1.0.0', '==0.1.0', '==3.0.0'):
            array.append(
                PackageVersion(name='tensorflow',
                               version=version,
                               develop=False))

        assert sorted(pv.locked_version
                      for pv in array) == ['0.1.0', '1.0.0', '3.0.0']
    def test_from_pipfile_lock_entry(self, package_name, package_info, expected_values):
        """Test from pipfile lock entry."""
        package_version = PackageVersion.from_pipfile_lock_entry(package_name, package_info, develop=False, meta=_META)

        for name, value in expected_values.items():
            if name == "index":
                assert package_version.index.name == value
                continue

            assert (
                getattr(package_version, name) == value
            ), f"Expected value {name} for locked package {package_name} does not match: {value}"

        assert package_version.is_locked() is True
    def test_from_pipfile_entry(self, package_name, package_info, expected_values, is_locked):
        """Test from pipfile entry."""
        package_version = PackageVersion.from_pipfile_entry(package_name, package_info, develop=False, meta=_META)

        for name, value in expected_values.items():
            if name == "index":
                if value is None:
                    assert package_version.index is None
                    continue

                assert package_version.index is not None
                package_version.index.name == value
                continue

            assert (
                getattr(package_version, name) == value
            ), f"Expected value for {name} for instance does not match: {value}"

        assert package_version.is_locked() is is_locked
 def test_from_pipfile_entry_error(self, package_name, package_info):
     """Test from pipfile entry error."""
     with pytest.raises(UnsupportedConfiguration):
         PackageVersion.from_pipfile_entry(package_name, package_info, develop=False, meta=_META)
 def test_semver_error(self):
     """Test semver error."""
     with pytest.raises(InternalError):
         return PackageVersion(name="tensorflow", version=">1.0.0", develop=False).semantic_version
 def test_from_pipfile_lock_entry_error(self, package_name, package_info):
     """Test from pipfile lock entry error."""
     with pytest.raises(PipfileParseError):
         PackageVersion.from_pipfile_lock_entry(package_name, package_info, develop=False, meta=_META)
Ejemplo n.º 16
0
 def test_semver_error(self):
     with pytest.raises(InternalError):
         return PackageVersion(name='tensorflow',
                               version='>1.0.0',
                               develop=False).semantic_version