String matchers

The String matcher is the one you’d be using most of the time to match string arguments.

More specialized matchers can distinguish between native Python 2/3 types for strings and binary data.

class callee.strings.String[source]

Matches any string.

On Python 2, this means either str or unicode objects.
On Python 3, this means str objects exclusively.
class callee.strings.Unicode[source]

Matches a Unicode string.

On Python 2, this means unicode objects exclusively.
On Python 3, this means str objects exclusively.
class callee.strings.Bytes[source]

Matches a byte array, i.e. the bytes type.

On Python 2, bytes class is identical to str class.
On Python 3, byte strings are separate class, distinct from str.

Patterns

These matchers check whether the string is of certain form.

Matching may be done based on prefix, suffix, or one of the various ways of specifying strings patterns, such as regular expressions.

class callee.strings.StartsWith(prefix)[source]

Matches a string starting with given prefix.

class callee.strings.EndsWith(suffix)[source]

Matches a string ending with given suffix.

class callee.strings.Glob(pattern, case=None)[source]

Matches a string against a Unix shell wildcard pattern.

See the fnmatch module for more details about those patterns.

Parameters:
  • pattern – Pattern to match against
  • case

    Case sensitivity setting. Possible options:

    • 'system' or None: case sensitvity is system-dependent (this is the default)
    • True: matching is case-sensitive
    • False: matching is case-insensitive
class callee.strings.Regex(pattern, flags=0)[source]

Matches a string against a regular expression.

Parameters:
  • pattern – Regular expression to match against. It can be given as string, or as a compiled regular expression object
  • flags – Flags to use with a regular expression passed as string