Skip to content

Commit

Permalink
Uncommented all invalid test cases
Browse files Browse the repository at this point in the history
Add ABOUT file and NOTICE

Signed-off-by: ziadhany <[email protected]>
  • Loading branch information
ziadhany committed Jan 3, 2024
1 parent bb7a7fd commit de3d5f6
Show file tree
Hide file tree
Showing 20 changed files with 468 additions and 80 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ For each scheme, **univers** provides an implementation for:
- converting a range back to its scheme-native range syntax and to the
``vers`` syntax.

**univers** implements ``vers``, an experimental unified and mostly universal
ma**univers** implements ``vers``, an experimental unified and mostly universal
version range syntax. It can parse and convert an existing native version range
strings to this unified syntax. For example, this means:

Expand Down
11 changes: 7 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.intersphinx',
"sphinx.ext.intersphinx",
]

# This points to aboutcode.readthedocs.io
# In case of "undefined label" ERRORS check docs on intersphinx to troubleshoot
# Link was created at commit - https://github.com/nexB/aboutcode/commit/faea9fcf3248f8f198844fe34d43833224ac4a83

intersphinx_mapping = {
'aboutcode': ('https://aboutcode.readthedocs.io/en/latest/', None),
'scancode-workbench': ('https://scancode-workbench.readthedocs.io/en/develop/', None),
"aboutcode": ("https://aboutcode.readthedocs.io/en/latest/", None),
"scancode-workbench": (
"https://scancode-workbench.readthedocs.io/en/develop/",
None,
),
}


Expand All @@ -62,7 +65,7 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

master_doc = 'index'
master_doc = "index"

html_context = {
"css_files": [
Expand Down
5 changes: 4 additions & 1 deletion etc/scripts/utils_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,10 @@ def dists_from_paths_or_urls(cls, paths_or_urls):
dists.append(dist)
if TRACE_DEEP:
print(
" ===> dists_from_paths_or_urls:", dist, "with URL:", dist.download_url
" ===> dists_from_paths_or_urls:",
dist,
"with URL:",
dist.download_url,
)
except InvalidDistributionFilename:
if TRACE_DEEP:
Expand Down
5 changes: 4 additions & 1 deletion src/univers/conan/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,7 @@ def __lt__(self, other):
else:
return self._nonzero_items < other._nonzero_items
else: # None of them is pre-release
return (self._nonzero_items, self._build) < (other._nonzero_items, other._build)
return (self._nonzero_items, self._build) < (
other._nonzero_items,
other._build,
)
4 changes: 3 additions & 1 deletion src/univers/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ def compare_strings(version1, version2):
logger.debug("Comparing non-digit prefixes %r and %r ..", p1, p2)
for c1, c2 in zip_longest(p1, p2, fillvalue=""):
logger.debug(
"Performing lexical comparison between characters %r and %r ..", c1, c2
"Performing lexical comparison between characters %r and %r ..",
c1,
c2,
)
o1 = mapping.get(c1)
o2 = mapping.get(c2)
Expand Down
6 changes: 4 additions & 2 deletions src/univers/version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ def from_native(cls, string):
comparator = ">"
constraints.append(
VersionConstraint(
comparator=comparator, version=cls.version_class(str(lower_bound))
comparator=comparator,
version=cls.version_class(str(lower_bound)),
)
)

Expand All @@ -762,7 +763,8 @@ def from_native(cls, string):
comparator = "<"
constraints.append(
VersionConstraint(
comparator=comparator, version=cls.version_class(str(upper_bound))
comparator=comparator,
version=cls.version_class(str(upper_bound)),
)
)

Expand Down
16 changes: 10 additions & 6 deletions src/univers/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,18 +488,22 @@ def __lt__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
# Check if versions have the same base, and `one and only one` of them is a pre-release.
if (self.major, self.minor, self.build) == (other.major, other.minor, other.build) and (
self.is_prerelease() != other.is_prerelease()
):
if (self.major, self.minor, self.build) == (
other.major,
other.minor,
other.build,
) and (self.is_prerelease() != other.is_prerelease()):
return self.is_prerelease()
return self.value.__lt__(other.value)

def __gt__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
if (self.major, self.minor, self.build) == (other.major, other.minor, other.build) and (
self.is_prerelease() != other.is_prerelease()
):
if (self.major, self.minor, self.build) == (
other.major,
other.minor,
other.build,
) and (self.is_prerelease() != other.is_prerelease()):
return other.is_prerelease()
return self.value.__gt__(other.value)

Expand Down
12 changes: 10 additions & 2 deletions tests/nuget/test_nuget_floating_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def test_FloatRange_OutsideOfRange():

def test_FloatRange_OutsideOfRangeLower():
vrange = VersionRange("[1.0.*, 2.0.0)")
versions = [NuGetVersion("0.1.0"), NuGetVersion("0.2.0"), NuGetVersion("1.0.0-alpha.2")]
versions = [
NuGetVersion("0.1.0"),
NuGetVersion("0.2.0"),
NuGetVersion("1.0.0-alpha.2"),
]
assert not vrange.FindBestMatch(versions)


Expand All @@ -64,7 +68,11 @@ def test_FloatRange_OutsideOfRangeHigher():

def test_FloatRange_OutsideOfRangeOpen():
vrange = VersionRange("[1.0.*, )")
versions = [NuGetVersion("0.1.0"), NuGetVersion("0.2.0"), NuGetVersion("1.0.0-alpha.2")]
versions = [
NuGetVersion("0.1.0"),
NuGetVersion("0.2.0"),
NuGetVersion("1.0.0-alpha.2"),
]
assert not vrange.FindBestMatch(versions)


Expand Down
5 changes: 4 additions & 1 deletion tests/nuget/test_nuget_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
("1.2.3", "1.2.3"),
("1.2.3-alpha", "1.2.3-alpha"),
("1.2.3-X.y.3+Meta-2", "1.2.3-x.y.3+Meta-2"),
("1.2.3-X.yZ.3.234.243.3242342+METADATA", "1.2.3-x.yz.3.234.243.3242342+METADATA"),
(
"1.2.3-X.yZ.3.234.243.3242342+METADATA",
"1.2.3-x.yz.3.234.243.3242342+METADATA",
),
("1.2.3-X.y3+0", "1.2.3-x.y3+0"),
("1.2.3-X+0", "1.2.3-x+0"),
("1.2.3+0", "1.2.3+0"),
Expand Down
5 changes: 4 additions & 1 deletion tests/nuget/test_nuget_version_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ def test_ParseVersionRangeSingleDigit():

def test_VersionRange_Exact():
versionInfo = NugetVersionRange.from_native(
nuget.Version.from_string(4, 3, 0), True, nuget.Version.from_string(4, 3, 0), True
nuget.Version.from_string(4, 3, 0),
True,
nuget.Version.from_string(4, 3, 0),
True,
)
assert versionInfo.Satisfies(nuget.Version.from_string("4.3.0"))

Expand Down
16 changes: 13 additions & 3 deletions tests/nuget/test_nuget_version_range_float_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def test_VersionRangeFloatParsing_PrereleaseWithNumericOnlyLabelVerifyMinVersion
("1.0.0-0+0-0"),
],
)
def test_VersionRangeFloatParsing_PrereleaseWithNumericOnlyLabelVerifySatisfies(version):
def test_VersionRangeFloatParsing_PrereleaseWithNumericOnlyLabelVerifySatisfies(
version,
):
vrange = NugetVersionRange.from_native("1.0.0-*")
assert vrange.Satisfies(nuget.Version(version))

Expand Down Expand Up @@ -283,8 +285,16 @@ def test_VersionRangeFloatParsing_CorrectFloatRange(rangeString):
("1.1.0;1.2.0-rc.1;1.2.0-rc.2;2.0.0;3.0.0-beta.1", "*-*", "3.0.0-beta.1"),
("1.1.0;1.2.0-rc.1;1.2.0-rc.2;2.0.0;3.0.0-beta.1", "1.*-*", "1.2.0-rc.2"),
("1.1.0;1.2.0-rc.1;1.2.0-rc.2;2.0.0;3.0.0-beta.1", "*-rc.*", "2.0.0"),
("1.1.0;1.2.0-rc.1;1.2.0-rc.2;1.2.0-rc1;2.0.0;3.0.0-beta.1", "1.*-rc*", "1.2.0-rc1"),
("1.1.0;1.2.0-rc.1;1.2.0-rc.2;1.2.0-rc1;1.10.0;2.0.0;3.0.0-beta.1", "1.1*-*", "1.10.0"),
(
"1.1.0;1.2.0-rc.1;1.2.0-rc.2;1.2.0-rc1;2.0.0;3.0.0-beta.1",
"1.*-rc*",
"1.2.0-rc1",
),
(
"1.1.0;1.2.0-rc.1;1.2.0-rc.2;1.2.0-rc1;1.10.0;2.0.0;3.0.0-beta.1",
"1.1*-*",
"1.10.0",
),
],
)
def test_VersionRangeFloatParsing_FindsBestMatch(availableVersions, declaredRange, expectedVersion):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cargo_version.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
about_resource: |
test_cargo_version_range.py
test_cargo_version.py

download_url: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
7 changes: 6 additions & 1 deletion tests/test_cargo.py → tests/test_cargo_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ def test_compare():
version_list,
)
def test_cargo(
version, expected_major, expected_minor, expected_patch, expected_prerelease, expected_build
version,
expected_major,
expected_minor,
expected_patch,
expected_prerelease,
expected_build,
):
# https://github.com/dtolnay/semver/blob/master/tests/test_version.rs :
v1 = CargoVersion(version)
Expand Down
Loading

0 comments on commit de3d5f6

Please sign in to comment.