| 316 | |
| 317 | @classmethod |
| 318 | def tearDownClass(cls): |
| 319 | drop_db = True |
| 320 | |
| 321 | # TODO: pytst does not make results available to fixtures by default. |
| 322 | # we might be able to add a hook+class fixture to help with this, but |
| 323 | # that adds quite a bit of complexity. For now, pytest will always drop the db. |
| 324 | # https://docs.pytest.org/en/stable/example/simple.html#making-test-result-information-available-in-fixtures |
| 325 | # When someone does decide to tackle this, we will probably need to rename the db |
| 326 | # for later inspection so subsequent tests still have a clean starting point as |
| 327 | # pytest will not necessarily stop on failure like nosetest did. |
| 328 | if cls.current_result and ( |
| 329 | cls.current_result.errors or cls.current_result.failures |
| 330 | ): |
| 331 | # Don't drop DB on test failure |
| 332 | drop_db = False |
| 333 | |
| 334 | if drop_db: |
| 335 | cls._drop_db() |
| 336 | |
| 337 | def run(self, result=None): |
| 338 | # Remember result for use in tearDown and tearDownClass |