API

class expectly._expect.expect(response_under_test)

The main class in this library. Provides the test methods.

classmethod add_assertion(name, assertion_callable, is_property=False, predicate_str=None)

Helper function to add an assertion to the expect class

Parameters:
  • name
  • assertion_callable
  • is_property
  • predicate_str
Returns:

classmethod add_join_word(word, predicate_str=None)

Adds a non sementically meaningful join word, e.g. “to”, “and”, etc

Parameters:
  • word
  • predicate_str
Returns:

and_
Returns:
assertion

Composes the current human readable assertion

Returns:a str
be
Returns:
contains(value)
encoding(encoding)
equal(value)
equals(value)
exactly_like(regex)
get()

A lazy getter for the value under test

have
Returns:
header(header)

Tests that the header exists. Sets the header to the value_under_test

headers(headers)
json
like(regex)
not_

Changes the test method to be a negative assertion

Returns:
null
ok
path(path)
schema(schema)
status_code(code)
test(value=True)

The default test method. It asserts the passed value is true with the assertion clause

that
Returns:
the
Returns:
to
Returns:
update_test_method(fn)

Given a function calls that function when expectly.expect.test() is called.

Parameters:fn
Returns:
valid
value