diff --git a/fqdn/__init__.py b/fqdn/__init__.py index e8a4b91..4dde285 100644 --- a/fqdn/__init__.py +++ b/fqdn/__init__.py @@ -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) diff --git a/tests/test_fqdn.py b/tests/test_fqdn.py index af9e66f..fb3a59c 100644 --- a/tests/test_fqdn.py +++ b/tests/test_fqdn.py @@ -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", @@ -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