# This file is part of the Open Parts Database software # Copyright (C) 2022 Valentin Lorentz # # This program is free software: you can redistribute it and/or modify it under the # terms of the GNU Affero General Public License version 3, as published by the # Free Software Foundation. # # This program is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License along with # this program. If not, see . """ pytest fixtures """ import pytest from opdb.db import Db def iter_subclasses(cls): """ Recursively yields all subclasses of a class. """ yield cls for subcls in cls.__subclasses__(): yield from iter_subclasses(subcls) @pytest.fixture def opdb_db(postgresql) -> Db: """ pytest fixture which yields an empty initialized OPDB database. """ db = Db(postgresql) db.init() return db