샘플
packaging 26.3: licenses.InvalidLicenseExpression
검증된 샘플 — pypi packaging 26.3: licenses.InvalidLicenseExpression. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:6e1f9a6c9b319c3e4e6d5cd733c55e74e476c10543892bb106b50c1533898b5d
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-02 |
케이스
HOW- 목표
- verify packaging.licenses.InvalidLicenseExpression in pkg:pypi/packaging@26.3
- 패키지
- 심벌
-
- packaging.licenses.InvalidLicenseExpression
- 생성일
- 2026-09-02T13:31:57Z
컨트랙트
- InvalidLicenseExpression is a subclass of ValueError
- canonicalize_license_expression raises InvalidLicenseExpression for empty or falsy strings
- canonicalize_license_expression raises InvalidLicenseExpression for unknown license identifiers
- canonicalize_license_expression raises InvalidLicenseExpression for invalid syntax or unbalanced parentheses
- canonicalize_license_expression raises InvalidLicenseExpression for unknown license exceptions with WITH clause
- canonicalize_license_expression raises InvalidLicenseExpression for invalid LicenseRef identifiers containing forbidden characters
- canonicalize_license_expression successfully normalizes valid license expressions and custom LicenseRef identifiers without raising InvalidLicenseExpression
파일
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- spec.json
- test/contract.py
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify packaging.licenses.InvalidLicenseExpression in pkg:pypi/packaging@26.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/packaging@26.3
Demonstrate these symbols/APIs:
- packaging.licenses.InvalidLicenseExpression
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:96f39853f028ad59f1f4b7646b0345b51473760c167c3fe50a939756b42e86ba","contract":["InvalidLicenseExpression is a subclass of ValueError","canonicalize_license_expression raises InvalidLicenseExpression for empty or falsy strings","canonicalize_license_expression raises InvalidLicenseExpression for unknown license identifiers","canonicalize_license_expression raises InvalidLicenseExpression for invalid syntax or unbalanced parentheses","canonicalize_license_expression raises InvalidLicenseExpression for unknown license exceptions with WITH clause","canonicalize_license_expression raises InvalidLicenseExpression for invalid LicenseRef identifiers containing forbidden characters","canonicalize_license_expression successfully normalizes valid license expressions and custom LicenseRef identifiers without raising InvalidLicenseExpression"],"goal":"verify packaging.licenses.InvalidLicenseExpression in pkg:pypi/packaging@26.3","kind":"HOW","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"symbols":["packaging.licenses.InvalidLicenseExpression"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/packaging@26.3"],"schemaVersion":1,"subject":"pkg:pypi/packaging@26.3","symbols":["packaging.licenses.InvalidLicenseExpression"],"verifierAdapter":"python@1"}
[project]
name = "verify-packaging-invalid-license-expression"
version = "0.1.0"
dependencies = [
"packaging==26.3",
]
packaging==26.3
{
"schemaVersion": 1,
"goal": "verify packaging.licenses.InvalidLicenseExpression in pkg:pypi/packaging@26.3",
"kind": "HOW",
"packages": [
"pkg:pypi/packaging@26.3"
],
"symbols": [
"packaging.licenses.InvalidLicenseExpression"
]
}
import sys
from packaging.licenses import (
InvalidLicenseExpression,
NormalizedLicenseExpression,
canonicalize_license_expression,
)
def test_invalid_license_expression_inheritance():
# Assertion 1: InvalidLicenseExpression is a subclass of ValueError
assert issubclass(InvalidLicenseExpression, ValueError), (
"InvalidLicenseExpression must inherit from ValueError"
)
assert issubclass(InvalidLicenseExpression, Exception), (
"InvalidLicenseExpression must inherit from Exception"
)
err = InvalidLicenseExpression("test error")
assert isinstance(err, ValueError)
assert str(err) == "test error"
def test_empty_license_expression():
# Assertion 2: canonicalize_license_expression raises InvalidLicenseExpression for empty or falsy strings
try:
canonicalize_license_expression("")
assert False, "Expected InvalidLicenseExpression for empty string"
except InvalidLicenseExpression as exc:
assert "Invalid license expression" in str(exc)
def test_unknown_license_identifier():
# Assertion 3: canonicalize_license_expression raises InvalidLicenseExpression for unknown license identifiers
unknown_ids = ["Not-A-Real-License", "Invalid-License-v1.0", "custom_lic"]
for unknown_id in unknown_ids:
try:
canonicalize_license_expression(unknown_id)
assert False, f"Expected InvalidLicenseExpression for unknown license {unknown_id}"
except InvalidLicenseExpression as exc:
assert "Unknown license" in str(exc)
def test_syntax_and_parentheses_errors():
# Assertion 4: canonicalize_license_expression raises InvalidLicenseExpression for invalid syntax or unbalanced parentheses
invalid_expressions = [
"(MIT",
"MIT)",
"MIT AND",
"AND MIT",
"MIT OR",
"MIT AND OR Apache-2.0",
"()",
"(MIT AND)",
]
for expr in invalid_expressions:
try:
canonicalize_license_expression(expr)
assert False, f"Expected InvalidLicenseExpression for invalid syntax: {expr}"
except InvalidLicenseExpression as exc:
assert "Invalid license expression" in str(exc)
def test_unknown_license_exception():
# Assertion 5: canonicalize_license_expression raises InvalidLicenseExpression for unknown license exceptions with WITH clause
invalid_with_expressions = [
"Apache-2.0 WITH",
"Apache-2.0 WITH Unknown-Exception-1.0",
"WITH LLVM-exception",
"MIT WITH WITH LLVM-exception",
]
for expr in invalid_with_expressions:
try:
canonicalize_license_expression(expr)
assert False, f"Expected InvalidLicenseExpression for invalid WITH expression: {expr}"
except InvalidLicenseExpression as exc:
assert (
"Unknown license exception" in str(exc)
or "Invalid license expression" in str(exc)
)
def test_invalid_licenseref_identifier():
# Assertion 6: canonicalize_license_expression raises InvalidLicenseExpression for invalid LicenseRef identifiers containing forbidden characters
invalid_refs = [
"LicenseRef-invalid@char",
"LicenseRef-invalid/slash",
"LicenseRef-invalid whitespace",
"LicenseRef-bad+",
]
for expr in invalid_refs:
try:
canonicalize_license_expression(expr)
assert False, f"Expected InvalidLicenseExpression for invalid LicenseRef: {expr}"
except InvalidLicenseExpression as exc:
assert (
"Invalid licenseref" in str(exc)
or "Invalid license expression" in str(exc)
)
def test_valid_license_expressions_pass():
# Assertion 7: canonicalize_license_expression successfully normalizes valid license expressions and custom LicenseRef identifiers without raising InvalidLicenseExpression
valid_cases = [
("mit", "MIT"),
("apache-2.0", "Apache-2.0"),
("bsd-3-clause", "BSD-3-Clause"),
("mit and apache-2.0", "MIT AND Apache-2.0"),
("mit or (apache-2.0 and bsd-2-clause)", "MIT OR (Apache-2.0 AND BSD-2-Clause)"),
("apache-2.0 with llvm-exception", "Apache-2.0 WITH LLVM-exception"),
("LicenseRef-Custom-1.0", "LicenseRef-Custom-1.0"),
("licenseref-proprietary", "LicenseRef-proprietary"),
("MIT AND LicenseRef-Custom.Doc", "MIT AND LicenseRef-Custom.Doc"),
]
for raw, expected in valid_cases:
result = canonicalize_license_expression(raw)
assert result == expected, f"Expected {expected}, got {result}"
assert isinstance(result, str)
def main():
test_invalid_license_expression_inheritance()
test_empty_license_expression()
test_unknown_license_identifier()
test_syntax_and_parentheses_errors()
test_unknown_license_exception()
test_invalid_licenseref_identifier()
test_valid_license_expressions_pass()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
오리진 시더
익명