def test_nested_selection_error(self): with pytest.raises(quiz.SelectionError) as exc: quiz.validate(Dog, _.owner[_.hobbies[_.foo]]) assert exc.value == quiz.SelectionError( Dog, 'owner', quiz.SelectionError( Human, 'hobbies', quiz.SelectionError(Hobby, 'foo', quiz.NoSuchField())))
def test_no_such_field(self): with pytest.raises(quiz.SelectionError) as exc: quiz.validate(Dog, _.name.foo.knows_command(command=Command.SIT)) assert exc.value == quiz.SelectionError(Dog, 'foo', quiz.NoSuchField())
def test_no_such_field_str(): exc = quiz.NoSuchField() assert str(exc) == 'field does not exist'