def test_accepts_fails_with_python_versions_mismatch(): dependency = Dependency("A", "^1.0") dependency.python_versions = "^3.6" package = Package("B", "1.4") package.python_versions = "~3.5" assert not dependency.accepts(package)
def test_accepts_python_versions(): dependency = Dependency("A", "^1.0") dependency.python_versions = "^3.6" package = Package("A", "1.4") package.python_versions = "~3.6" assert dependency.accepts(package)
def test_to_pep_508_in_extras(): dependency = Dependency("Django", "^1.23") dependency.in_extras.append("foo") result = dependency.to_pep_508() assert result == 'Django (>=1.23,<2.0); extra == "foo"' result = dependency.to_pep_508(with_extras=False) assert result == "Django (>=1.23,<2.0)" dependency.in_extras.append("bar") result = dependency.to_pep_508() assert result == 'Django (>=1.23,<2.0); extra == "foo" or extra == "bar"' dependency.python_versions = "~2.7 || ^3.6" result = dependency.to_pep_508() assert result == ("Django (>=1.23,<2.0); " "(" 'python_version >= "2.7" and python_version < "2.8" ' 'or python_version >= "3.6" and python_version < "4.0"' ") " 'and (extra == "foo" or extra == "bar")') result = dependency.to_pep_508(with_extras=False) assert result == ("Django (>=1.23,<2.0); " 'python_version >= "2.7" and python_version < "2.8" ' 'or python_version >= "3.6" and python_version < "4.0"')
def test_with_constraint(): dependency = Dependency( "foo", "^1.2.3", optional=True, category="dev", allows_prereleases=True, extras=["bar", "baz"], ) dependency.marker = parse_marker( 'python_version >= "3.6" and python_version < "4.0"') dependency.transitive_marker = parse_marker( 'python_version >= "3.7" and python_version < "4.0"') dependency.python_versions = "^3.6" dependency.transitive_python_versions = "^3.7" new = dependency.with_constraint("^1.2.6") assert new.name == dependency.name assert str(new.constraint) == ">=1.2.6,<2.0.0" assert new.is_optional() assert new.category == "dev" assert new.allows_prereleases() assert set(new.extras) == {"bar", "baz"} assert new.marker == dependency.marker assert new.transitive_marker == dependency.transitive_marker assert new.python_constraint == dependency.python_constraint assert new.transitive_python_constraint == dependency.transitive_python_constraint
def test_to_pep_508_with_patch_python_version(python_versions, marker): dependency = Dependency("Django", "^1.23") dependency.python_versions = python_versions expected = "Django (>=1.23,<2.0); {}".format(marker) assert expected == dependency.to_pep_508() assert marker == str(dependency.marker)
def _non_empty_term(self, constraint, is_positive): if constraint.is_empty(): return dep = Dependency(self.dependency.name, constraint) dep.python_versions = str(self.dependency.python_versions) return Term(dep, is_positive)
def test_to_pep_508(): dependency = Dependency("Django", "^1.23") result = dependency.to_pep_508() assert result == "Django (>=1.23,<2.0)" dependency = Dependency("Django", "^1.23") dependency.python_versions = "~2.7 || ^3.6" result = dependency.to_pep_508() assert (result == "Django (>=1.23,<2.0); " 'python_version >= "2.7" and python_version < "2.8" ' 'or python_version >= "3.6" and python_version < "4.0"')