You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/08/18 11:53:43 UTC

[GitHub] [airflow] ashb commented on a change in pull request #17556: Use `dag_maker` fixture in some test files under tests/models

ashb commented on a change in pull request #17556:
URL: https://github.com/apache/airflow/pull/17556#discussion_r691163847



##########
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:
       Yeah, caplog behaves slightly differently. This test is good enough.




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org