lib.version.Version.__resolved_id(): Resolve VERSION to core
__resolved_id() returns the full version if only VERSION was specified, fix that. Also: raise Version.Error instead of a bare Exception. Tests written by AI. Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
149739cc93
commit
f689e4ba94
2 changed files with 21 additions and 15 deletions
|
|
@ -62,7 +62,7 @@ except Version.Error:
|
|||
|
||||
# The lookup resolves the macros
|
||||
d = Dependency('foo = VERSION', app.get_version)
|
||||
assert d.constraint_str() == 'foo = 1.2.3-45'
|
||||
assert d.constraint_str() == 'foo = 1.2.3'
|
||||
d = Dependency('foo = VERSION', app.get_version)
|
||||
assert d.constraint_str(include_revision = False) == 'foo = 1.2.3'
|
||||
# Only the VERSION macro loses its revision, VERSION-REVISION and
|
||||
|
|
@ -89,7 +89,7 @@ except Dependency.Error:
|
|||
|
||||
# The lookup uses the base name, not the subpackage name
|
||||
d = Dependency('foo-devel = VERSION', app.get_version)
|
||||
assert d.constraint_str() == 'foo-devel = 1.2.3-45'
|
||||
assert d.constraint_str() == 'foo-devel = 1.2.3'
|
||||
# Unknown projects fail when untemplating
|
||||
try:
|
||||
Dependency('baz = VERSION', app.get_version).constraint_str()
|
||||
|
|
@ -105,8 +105,8 @@ def mapper(project: str) -> str:
|
|||
return '1.2.3-45'
|
||||
|
||||
d = Dependency('foo = VERSION', mapper)
|
||||
assert d.constraint_str() == 'foo = 1.2.3-45'
|
||||
assert d.constraint_str() == 'foo = 1.2.3-45'
|
||||
assert d.constraint_str() == 'foo = 1.2.3'
|
||||
assert d.constraint_str() == 'foo = 1.2.3'
|
||||
assert calls == ['foo']
|
||||
|
||||
# as_range expands full boundaries into a revision range
|
||||
|
|
@ -122,12 +122,12 @@ constraint = d.constraint_str(untemplated = False, as_range = True)
|
|||
assert constraint == 'foo >= VERSION-REVISION foo < 1.2.4'
|
||||
# VERSION is not full, so a VERSION constraint is not expanded
|
||||
d = Dependency('foo = VERSION', app.get_version)
|
||||
assert d.constraint_str(as_range = True) == 'foo = 1.2.3-45'
|
||||
assert d.constraint_str(as_range = True) == 'foo = 1.2.3'
|
||||
d = Dependency('foo >= VERSION', app.get_version)
|
||||
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3-45'
|
||||
assert d.constraint_str(as_range = True) == 'foo >= 1.2.3'
|
||||
# '<' and '<=' are not expanded
|
||||
d = Dependency('foo <= VERSION', app.get_version)
|
||||
assert d.constraint_str(as_range = True) == 'foo <= 1.2.3-45'
|
||||
assert d.constraint_str(as_range = True) == 'foo <= 1.2.3'
|
||||
# versions without a full major.minor.micro-revision are not expanded
|
||||
d = Dependency('foo = 1.0', app.get_version)
|
||||
assert d.constraint_str(as_range = True) == 'foo = 1.0'
|
||||
|
|
@ -213,7 +213,7 @@ assert deps[2].constraint_str() == 'baz'
|
|||
|
||||
# parse_deps_spec passes the lookup to the created packages
|
||||
deps = Dependency.parse_deps_spec('foo = VERSION, bar', app.get_version)
|
||||
assert deps[0].constraint_str() == 'foo = 1.2.3-45'
|
||||
assert deps[0].constraint_str() == 'foo = 1.2.3'
|
||||
assert deps[1].constraint_str() == 'bar'
|
||||
|
||||
# Malformed specs are rejected when parsed
|
||||
|
|
|
|||
Loading…
Reference in a new issue