Skip to content
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

Accept empty string on construction #46

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fqdn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, fqdn, *nothing, **kwargs):
if unknown_kwargs:
raise ValueError("got extra kwargs: {}".format(unknown_kwargs))

if not (fqdn and isinstance(fqdn, str)):
if not isinstance(fqdn, str):
raise ValueError("fqdn must be str")
self._fqdn = fqdn.lower()
self._allow_underscores = kwargs.get("allow_underscores", False)
Expand Down
8 changes: 6 additions & 2 deletions tests/test_fqdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def test_str(self, a_u):
f = FQDN(d, allow_underscores=a_u)
assert f.absolute == str(f)

def test_empty(self, a_u):
d = ""
f = FQDN(d, allow_underscores=a_u)
assert not f.is_valid

def test_rfc_1035_s_2_3_4__label_max_length(self, a_u):
assert FQDN(
"www.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
Expand Down Expand Up @@ -159,8 +164,7 @@ def test_min_labels_defaults_to_require_2(self):
assert not dn.is_valid

def test_min_labels_valid_set_to_1(self):
with pytest.raises(ValueError):
FQDN("", min_labels=1).is_valid
assert not FQDN("", min_labels=1).is_valid
assert FQDN("label", min_labels=1).is_valid
assert not FQDN(".label", min_labels=1).is_valid
assert FQDN("label.babel", min_labels=1).is_valid
Expand Down