Skip to content

Commit b3ca8b3

Browse files
committed
Fix tests
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 83c1a6a commit b3ca8b3

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
PYTHON_EXE?=python3
2727
ACTIVATE?=. bin/activate;
2828
VIRTUALENV_PYZ=thirdparty/virtualenv.pyz
29-
BLACK_ARGS=--exclude=".cache|lib|bin|var|^spec/" --line-length 100
29+
BLACK_ARGS=src/ --exclude="\.cache|lib|bin|var" --line-length 100
3030

3131
virtualenv:
3232
@echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}"
@@ -52,7 +52,7 @@ isort:
5252

5353
black:
5454
@echo "-> Apply black code formatter"
55-
@${ACTIVATE} black ${BLACK_ARGS} .
55+
@${ACTIVATE} black ${BLACK_ARGS}
5656

5757
mypy:
5858
@echo "-> Type check the Python code."

src/packageurl/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,15 @@ def from_string(cls, purl: str) -> Self:
463463
type_, sep, remainder = remainder.partition("/")
464464
if not type_ or not sep:
465465
raise ValueError(f"purl is missing the required type component: {purl!r}.")
466-
467-
# check if type starts with a number
466+
467+
if not all(c in string.ascii_letters + string.digits + "-._" for c in type_):
468+
raise ValueError(
469+
f"purl type must be composed only of ASCII letters and numbers, period, dash and underscore: {type_!r}."
470+
)
471+
472+
if ":" in type_:
473+
raise ValueError(f"purl type cannot contain a colon: {type_!r}.")
474+
468475
if type_[0] in string.digits:
469476
raise ValueError(f"purl type cannot start with a number: {type_!r}.")
470477

tests/test_purl_spec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def test_parse(description, input_str, expected_output, expected_failure):
3131
if expected_failure:
3232
with pytest.raises(Exception):
3333
PackageURL.from_string(input_str)
34+
# assert None ==PackageURL.from_string(input_str)
3435
else:
3536
result = PackageURL.from_string(input_str)
3637
assert result.to_string() == expected_output

0 commit comments

Comments
 (0)