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



##########
File path: tests/cli/commands/test_task_command.py
##########
@@ -245,6 +251,99 @@ def test_local_run(self):
         self.assertEqual(state, State.SUCCESS)
 
 
+class TestLogsfromTaskRunCommand(unittest.TestCase):
+
+    def setUp(self) -> None:
+        self.dag_id = "test_logging_dag"
+        self.task_id = "test_task"
+        reset(self.dag_id)
+        self.execution_date_str = timezone.make_aware(datetime(2017, 1, 
1)).isoformat()
+        self.log_dir = conf.get('logging', 'base_log_folder')
+        self.log_filename = 
f"{self.dag_id}/{self.task_id}/{self.execution_date_str}/1.log"
+        self.ti_log_file_path = os.path.join(self.log_dir, self.log_filename)
+        self.parser = cli_parser.get_parser()
+        try:
+            os.remove(self.ti_log_file_path)
+        except OSError:
+            pass
+
+    def tearDown(self) -> None:
+        reset(self.dag_id)
+        try:
+            os.remove(self.ti_log_file_path)
+        except OSError:
+            pass
+
+    def assert_log_line(self, text, logs_list):
+        """
+        Get Log Line and assert only 1 Entry exists with the given text. Also 
check that
+        "logging_mixin" line does not appear in that log line to avoid 
duplicate loggigng as below:
+
+        [2020-06-24 16:47:23,537] {logging_mixin.py:91} INFO - [2020-06-24 
16:47:23,536] {python.py:135}
+        """
+        log_lines = [log for log in logs_list if text in log]
+        self.assertEqual(len(log_lines), 1)
+        log_line = log_lines[0]
+        if "Print" not in log_line:

Review comment:
       ```suggestion
       def assert_log_line(self, text, logs_list, 
expect_from_logging_mixin=False):
           """
           Get Log Line and assert only 1 Entry exists with the given text. 
Also check that
           "logging_mixin" line does not appear in that log line to avoid 
duplicate loggigng as below:
   
           [2020-06-24 16:47:23,537] {logging_mixin.py:91} INFO - [2020-06-24 
16:47:23,536] {python.py:135}
           """
           log_lines = [log for log in logs_list if text in log]
           self.assertEqual(len(log_lines), 1)
           log_line = log_lines[0]
           if expect_from_logging_mixin:
   ```




----------------------------------------------------------------
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]


Reply via email to