uranusjr commented on pull request #15141: URL: https://github.com/apache/airflow/pull/15141#issuecomment-812288990
Both `TestApiKerberos._set_attrs` and `dagbag_to_db` are [autouse fixtures](https://docs.pytest.org/en/stable/fixture.html#autouse-fixtures-fixtures-you-don-t-have-to-request), which means they are loaded automatically for every test in `test_kerberos_auth.py`. `_set_attrs` here uses the default (`function`) scope, which means it is wrapped around every test. The part before `yield` is like `setUp`, and the part after `tearDown` for `unittest.TestCase`. `dagbag_to_db` is `module`-scoped, so the code is automatically executed once for all tests in this module, in other words like `setUpClass` and `tearDownClass` but for the entire module. The only performance improvements in this PR comes from `app_for_kerberos`, which is `module`-scoped and therefore creates the Flask app instance only once for this module, instead of once for every test. But these autouse fixtures need to be created from the TestCase setup/teardown equivalents since `unittest.TestCase` subclasses cannot load pytest fixtures. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
