-
Notifications
You must be signed in to change notification settings - Fork 74
NpmSpec Comparison Between Prerelease Versions is Wrong #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This looks indeed like a bug; I don't understand why the current tests fail to detect it :/ |
Because you only test '>1.2.3-alpha.3' and '>=1.2.3-alpha.3' cases (GT and GTE). No cases for prerelease versions with LT and LTE. :) |
possibly related: >>> NpmSpec(">=2.0.1-").match(Version("2.0.1-rc1"))
False
>>> NpmSpec(">=2.0.1-0").match(Version("2.0.1-rc1"))
True I believe |
oh and the same issue with |
Here's another example that doesn't seem correct.
The same examples in
|
Any news about this?
|
Hi, any news about this? There are many cases in which the behavior differs from the This test checks that the behavior is consistent with the import pytest
from semantic_version import NpmSpec, Version
@pytest.mark.parametrize(
"version, spec, satisfies",
[
("1.0.0", "1.0.0", True),
("2.0.0", "1.0.0", False),
("1.0.0", "2.0.0", False),
("1.2.0", "<1.5.0 >1.0.0 || >1.5.0 <2.0.0", True),
("2.0.0", "<1.5.0 >1.0.0 || >1.5.0 <2.0.0", False),
("1.5.0", "<1.5.0 >1.0.0 || >1.5.0 <2.0.0", False),
("1.0.0-100", "1.0.0-100", True),
("1.0.0-200", "1.0.0-100", False),
("1.0.0", "1.0.0-100", False), # differs from node-semver
("1.0.0+100", "1.0.0+100", True),
("1.0.0+200", "1.0.0+100", True), # differs from node-semver
("1.0.0", "1.0.0+100", True), # differs from node-semver
("1.0.0-100", "<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200", True), # differs from node-semver
("1.0.0-199", "<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200", True), # differs from node-semver
("1.0.0-200", "<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200", False),
("1.0.0-150", "<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200", False),
("1.0.0+100", "<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200", False),
("1.0.0+199", "<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200", False),
("1.0.0+200", "<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200", False),
("1.0.0+150", "<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200", False),
],
)
def test_npm_spec(version: str, spec: str, satisfies: bool) -> None:
if satisfies:
assert Version(version) in NpmSpec(spec)
else:
assert Version(version) not in NpmSpec(spec) Output from
> s.satisfies("1.0.0","1.0.0")
true
> s.satisfies("2.0.0","1.0.0")
false
> s.satisfies("1.0.0","2.0.0")
false
> s.satisfies("1.2.0","<1.5.0 >1.0.0 || >1.5.0 <2.0.0")
true
> s.satisfies("2.0.0","<1.5.0 >1.0.0 || >1.5.0 <2.0.0")
false
> s.satisfies("1.5.0","<1.5.0 >1.0.0 || >1.5.0 <2.0.0")
false
> s.satisfies("1.0.0-100","1.0.0-100")
true
> s.satisfies("1.0.0-200","1.0.0-100")
false
> s.satisfies("1.0.0","1.0.0-100")
false
> s.satisfies("1.0.0+100","1.0.0+100")
true
> s.satisfies("1.0.0+200","1.0.0+100")
true
> s.satisfies("1.0.0","1.0.0+100")
true
> s.satisfies("1.0.0-100","<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200")
true
> s.satisfies("1.0.0-199","<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200")
true
> s.satisfies("1.0.0-200","<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200")
false
> s.satisfies("1.0.0-150","<1.0.0-150 >=1.0.0-100 || >1.0.0-150 <1.0.0-200")
false
> s.satisfies("1.0.0+100","<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200")
false
> s.satisfies("1.0.0+199","<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200")
false
> s.satisfies("1.0.0+200","<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200")
false
> s.satisfies("1.0.0+150","<1.0.0+150 >=1.0.0+100 || >1.0.0+150 <1.0.0+200")
false |
Version is 2.8.5.
They should be false.
The text was updated successfully, but these errors were encountered: