String Helpers
- areSame(a: str | None, b: str | None) bool
Use
areSame()to assert that two strings contain the same characters in the same order.
Example
from punit import strings
a = 'hello'
b = 'hello'
c = 'world'
d = None
assert strings.areSame(a, b)
assert not strings.areSame(b, c)
assert strings.areSame(a, a)
assert strings.areSame(None, None)
assert not strings.areSame(a, None)
assert not strings.areSame(None, b)
- isNoneOrEmpty(string: str | None) bool
Use
isNoneOrEmpty()to assert that a string isNoneor empty.
Example
from punit import strings
a = 'hello'
b = ''
c = None
assert strings.isNoneOrEmpty(a)
assert strings.isNoneOrEmpty(b)
assert strings.isNoneOrEmpty(c)
assert not strings.isNoneOrEmpty(a)
assert not strings.isNoneOrEmpty(b)
- isNoneOrWhitespace(string: str | None) bool
Use
isNoneOrWhitespace()to assert that a string isNoneor whitespace.
Example
from punit import strings
a = 'hello'
b = ' \t'
c = None
assert strings.isNoneOrWhitespace(a)
assert strings.isNoneOrWhitespace(b)
assert strings.isNoneOrWhitespace(c)
assert not strings.isNoneOrWhitespace(a)
assert not strings.isNoneOrWhitespace(b)