Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixture for CLI tests requiring sample dags #26536

Merged

Conversation

dstandish
Copy link
Contributor

Add fixture for CLI tests requiring sample dags

I noticed that various CLI tests were failing (specifically in test_task_command.py) when run locally but not when run in breeze. I figured out the cause is that breeze has ('core', 'load_examples') set to true but I had it false locally. To fix this we can add a fixture that patches the conf settings. But we have to go one step further. If we grab the conf value in the default for the argument in DagBag, this means the value is fixed at the time the class gets defined. So the value cannot be changed later in runtime! The solution is to resolve the default on the fly each time an instance is created.

I noticed that various CLI tests were failing (specifically in test_task_command.py) when run locally but not when run in breeze.  I figured out the cause is that breeze has ('core', 'load_examples') set to true but I had it false locally.  To fix this we can add a fixture that patches the conf settings.  But we have to go one step further.  If we grab the conf value in the default for the argument in DagBag, this means the value is fixed at the time the class gets defined.  So the value cannot be changed later in runtime!  The solution is to resolve the default on the fly each time an instance is created.

We do the same for safe_mode while we're at it, because why not.
@dstandish dstandish force-pushed the fixture-for-tests-requiring-example-dags branch from 6784694 to 0189669 Compare September 21, 2022 00:33
@dstandish dstandish merged commit 3cd4df1 into apache:main Sep 21, 2022
@dstandish dstandish deleted the fixture-for-tests-requiring-example-dags branch September 21, 2022 04:37
@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Oct 18, 2022
@ephraimbuddy ephraimbuddy added this to the Airflow 2.4.2 milestone Oct 18, 2022
ephraimbuddy pushed a commit that referenced this pull request Oct 18, 2022
I noticed that various CLI tests were failing (specifically in test_task_command.py) when run locally but not when run in breeze.  I figured out the cause is that breeze has ('core', 'load_examples') set to true but I had it false locally.  To fix this we can add a fixture that patches the conf settings.  But we have to go one step further.  If we grab the conf value in the default for the argument in DagBag, this means the value is fixed at the time the class gets defined.  So the value cannot be changed later in runtime!  The solution is to resolve the default on the fly each time an instance is created.

We do the same for safe_mode while we're at it, because why not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants