joythief.strings module

Matchers for the text sequence type (str).

class joythief.strings.JsonString(expected=<object object>)[source]

Bases: Matcher[str]

Matches any str instance representing JSON.

Parameters:

expected (Any) – What the result of parsing the JSON should be. If omitted, any valid JSON string is matched.

class joythief.strings.StringMatching(pattern: Pattern[str])[source]
class joythief.strings.StringMatching(pattern: str, *, flags: int = 0)

Bases: Matcher[str]

Matches any str instance matching a regular expression.

Parameters:
  • pattern (str | Pattern[str]) – Regex pattern to match, as a string or compiled pattern.

  • flags (int) – Any flags to compile a str pattern with

Raises:

ValueError – if flags are provided with a pre-compiled pattern.

class joythief.strings.UrlString(*, scheme=None, hostname=None, path=None, query=None)[source]

Bases: Matcher[str]

Matches any str instance representing a URL.

The string is parsed with urlparse() and compared attribute-by-attribute. Any attributes not provided are ignored.

Parameters:
Raises:

TypeError – if no arguments are provided.