Skip to content

Tests fail after the first run #109

Closed
@laurentS

Description

@laurentS

I got very confused by the tests that were always passing in CI, but failing in my local dev environment.
After trying a variety of ideas, it turns out that the first test run after pruning all docker images and containers passes, but subsequent ones fail with:

self = <app.crud.crud_user.CRUDUser object at 0x7f6dddde08d0>, db_session = <sqlalchemy.orm.scoping.scoped_session object at 0x7f6dddac4f10>

    def update(
        self, db_session: Session, *, db_obj: ModelType, obj_in: UpdateSchemaType
    ) -> ModelType:
        obj_data = jsonable_encoder(db_obj)
>       update_data = obj_in.dict(skip_defaults=True)
E       AttributeError: 'User' object has no attribute 'dict'

app/app/crud/base.py:44: AttributeError

in two tests: test_get_users_normal_user_me and test_create_user_by_normal_user.

To reproduce, simply run the tests twice in a row from a fresh install. The first run will pass, the second one will fail.
To "reset" the tests, docker-compose exec db psql -U postgres and \c app then delete from public.user where id>1; and the tests will pass again.

I suspect this might have to do with some dependency that changed its api at some point, and the change didn't get caught in CI because this code path is not actually tested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions