Skip to content

Commit

Permalink
Merge pull request #168 from simleo/fix_is_url
Browse files Browse the repository at this point in the history
Fix is_url
  • Loading branch information
simleo authored Dec 21, 2023
2 parents 9137682 + 4dd1090 commit fd5b75e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rocrate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def is_url(string):
parts = urlsplit(string)
if os.name == "nt" and len(parts.scheme) == 1:
return False
return all((parts.scheme, parts.path))
return bool(parts.scheme)


def iso_now():
Expand Down
11 changes: 10 additions & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import pytest

from rocrate.utils import subclasses, get_norm_value
from rocrate.utils import subclasses, get_norm_value, is_url


class Pet:
Expand Down Expand Up @@ -53,3 +53,12 @@ def test_get_norm_value():
assert get_norm_value({"@id": "#xyz"}, "name") == []
with pytest.raises(ValueError):
get_norm_value({"@id": "#xyz", "name": [["foo"]]}, "name")


def test_is_url():
assert is_url("http://example.com/index.html")
assert is_url("http://example.com/")
assert is_url("http://example.com")
assert not is_url("/etc/")
assert not is_url("/etc")
assert not is_url("/")

0 comments on commit fd5b75e

Please sign in to comment.