[lang-ref] ( string_is_null_or_empty ) ( python )
@pytest.mark.parametrize(
's, expected',
[
('', True),
(' ', False),
('a', False),
(None, True),
([], False),
(0, False),
],
)
def test_string_is_null_or_empty(s, expected):
# is None + len
is_null_or_empty = (s is None or len(str(s)) == 0)
assert is_null_or_empty == expected
@pytest.mark.parametrize(
's, expected',
[
('', True),
(' ', False),
('a', False),
(None, True),
([], True), # !!!
(0, True), # !!!
],
)
def test_string_is_null_or_empty_alternative(s, expected):
# deprecated for me: misleading as IsNullOrEmpty
is_falsy = (not s)
assert is_falsy == expected