ephraimbuddy commented on a change in pull request #17556:
URL: https://github.com/apache/airflow/pull/17556#discussion_r687064786
##########
File path: tests/models/test_dagbag.py
##########
@@ -170,20 +172,20 @@ def my_flow():
assert dagbag.import_errors[tf_2.name].startswith("Ignoring DAG")
assert dagbag.dags == dags_in_bag # Should not change.
- def test_zip_skip_log(self):
+ def test_zip_skip_log(self, caplog):
"""
test the loading of a DAG from within a zip file that skips another
file because
it doesn't have "airflow" and "DAG"
"""
- with self.assertLogs() as cm:
- test_zip_path = os.path.join(TEST_DAGS_FOLDER, "test_zip.zip")
- dagbag = models.DagBag(dag_folder=test_zip_path,
include_examples=False)
+ caplog.set_level(logging.INFO)
+ test_zip_path = os.path.join(TEST_DAGS_FOLDER, "test_zip.zip")
+ dagbag = models.DagBag(dag_folder=test_zip_path,
include_examples=False)
- assert dagbag.has_logged
- assert (
- f'INFO:airflow.models.dagbag.DagBag:File
{test_zip_path}:file_no_airflow_dag.py '
- 'assumed to contain no DAGs. Skipping.' in cm.output
- )
+ assert dagbag.has_logged
+ assert (
+ f'File {test_zip_path}:file_no_airflow_dag.py '
+ 'assumed to contain no DAGs. Skipping.' in caplog.text
+ )
Review comment:
I could not get `caplog` to log exactly like the `unittest`, so I
stripped out the part that was not in order, and luckily it's not the important
part
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]