betty.test_utils.attr module - Betty documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# betty.test_utils.attr module

Test utilities for `betty.attr`.

class betty.test_utils.attr.AttrTestBase

  Bases: `Generic`[`_InstanceT`, `_ValueT`]

  A base class for testing `betty.attr.Attr` implementations.

  get_instances() → tuple[Sequence[_InstanceT], str]

    Get instances with an attribute under test.

    Returns:

      A 2-tuple with the instances, and the name of the attribute containing the `betty.attr.Attr` under test.

  async test___get___with_owner() → None

    Tests `__get__` implementations.

  async test___get___without_owner() → None

    Tests `__get__` implementations.

  test_get_attr() → None

    Tests `betty.attr.Attr.get_attr()` implementations.

class betty.test_utils.attr.MutableAttrTestBase

  Bases: `Generic`[`_InstanceT`, `_ValueT`, `_SetT`], `AttrTestBase`[`_InstanceT`, `_ValueT`]

  A base class for testing `betty.attr.MutableAttr` implementations.

  assert_eq(get_value: _ValueT, set_value: _SetT) → None

    Assert that a get value and a set value are equal.

  assert_ne(get_value: _ValueT, set_value: _SetT) → None

    Assert that a get value and a set value are not equal.

  get_instances() → tuple[Sequence[_InstanceT], str]

    Get instances with an attribute under test.

    Returns:

      A 2-tuple with the instances, and the name of the attribute containing the `betty.attr.Attr` under test.

  get_mutable_instances() → tuple[Sequence[tuple[_InstanceT, Sequence[_SetT]]], str]

    Get instances with a mutable attribute under test.

    Returns:

      A 2-tuple with the instances, and the name of the attribute containing the `betty.attr.MutableAttr` under test.

  async test___delete__() → None

    Tests `__delete__` implementations.

  async test___set__() → None

    Tests `__set__` implementations.

  test_del_attr() → None

    Tests `betty.attr.MutableAttr.del_attr()` implementations.

  test_new_attr() → None

    Tests `betty.attr.MutableAttr.del_attr()` implementations.

  test_set_attr() → None

    Tests `betty.attr.MutableAttr.set_attr()` implementations.