Example #1
0
def test_small_family():
    """Test count_descendants on a small example."""
    aura = Person('aura', [])
    zane = Person('zane', [])
    goku = Person('goku', [aura, zane])
    mina = Person('mina', [goku])
    assert mina.count_descendants() == 3
Example #2
0
def test_person_with_some_children(name, children):
    """Test count_descendants on a person with some children.

    Each child has *no* children of their own in this test case.
    """
    # children is a list of Person objects, each of whom have no children
    p = Person(name, children)

    # The number of descendants of p is equal to their number of children
    assert p.count_descendants() == len(children)