From 6f132c0342ab7aa438ed88d7c5f987cb52d8ca05 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Thu, 9 Sep 2021 16:42:13 -0700 Subject: Update tests / test harness. --- string_utils.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'string_utils.py') diff --git a/string_utils.py b/string_utils.py index 5eb03d2..0829846 100644 --- a/string_utils.py +++ b/string_utils.py @@ -28,7 +28,7 @@ URLS_RAW_STRING = ( r"([a-z-]+://)" # scheme r"([a-z_\d-]+:[a-z_\d-]+@)?" # user:password r"(www\.)?" # www. - r"((? bool: True >>> is_none_or_empty(None) True - >>> is_none_or_empty(" ") + >>> is_none_or_empty(" \t ") True >>> is_none_or_empty('Test') False @@ -175,18 +175,22 @@ def is_string(obj: Any) -> bool: def is_empty_string(in_str: Any) -> bool: + return is_empty(in_str) + + +def is_empty(in_str: Any) -> bool: """ Checks if input is a string and empty or only whitespace. - >>> is_empty_string('') + >>> is_empty('') True - >>> is_empty_string(' \t\t ') + >>> is_empty(' \t\t ') True - >>> is_empty_string('test') + >>> is_empty('test') False - >>> is_empty_string(100.88) + >>> is_empty(100.88) False - >>> is_empty_string([1, 2, 3]) + >>> is_empty([1, 2, 3]) False """ return is_string(in_str) and in_str.strip() == "" @@ -733,8 +737,6 @@ def is_ip(in_str: Any) -> bool: """ Checks if a string is a valid ip (either v4 or v6). - *Examples:* - >>> is_ip('255.200.100.75') True >>> is_ip('2001:db8:85a3:0000:0000:8a2e:370:7334') -- cgit v1.3