|
| 1 | +# ,---------, ____ _ __ |
| 2 | +# | ,-^-, | / __ )(_) /_______________ _____ ___ |
| 3 | +# | ( O ) | / __ / / __/ ___/ ___/ __ `/_ / / _ \ |
| 4 | +# | / ,--' | / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ |
| 5 | +# +------` /_____/_/\__/\___/_/ \__,_/ /___/\___/ |
| 6 | +# |
| 7 | +# Copyright (C) 2026 Bitcraze AB |
| 8 | +# |
| 9 | +# This program is free software: you can redistribute it and/or modify |
| 10 | +# it under the terms of the GNU General Public License as published by |
| 11 | +# the Free Software Foundation, either version 3 of the License, or |
| 12 | +# (at your option) any later version. |
| 13 | +# |
| 14 | +# This program is distributed in the hope that it will be useful, |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +# GNU General Public License for more details. |
| 18 | +# |
| 19 | +# You should have received a copy of the GNU General Public License |
| 20 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | +import pytest |
| 22 | + |
| 23 | +import cflib2 |
| 24 | + |
| 25 | + |
| 26 | +EXCEPTION_NAMES = [name for name in cflib2.__all__ if name.endswith("Error")] |
| 27 | + |
| 28 | + |
| 29 | +class TestExceptionHierarchy: |
| 30 | + """Verify that all custom exceptions inherit from CrazyflieError.""" |
| 31 | + |
| 32 | + @pytest.mark.parametrize("name", EXCEPTION_NAMES) |
| 33 | + def test_exception_is_subclass_of_crazyflie_error(self, name: str) -> None: |
| 34 | + exc_class = getattr(cflib2, name) |
| 35 | + assert issubclass(exc_class, cflib2.CrazyflieError) |
0 commit comments