This is an automated email from the ASF dual-hosted git repository.

jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new cdf96a8ad7 Fix Pytest caplog after PR #43153 (#43279)
cdf96a8ad7 is described below

commit cdf96a8ad7b9a8bf2abcb1b928d55d953057d8b1
Author: Jens Scheffler <[email protected]>
AuthorDate: Wed Oct 23 00:23:40 2024 +0200

    Fix Pytest caplog after PR #43153 (#43279)
    
    * Fix Pytest caplog after PR 43153
---
 providers/tests/edge/cli/test_edge_command.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/providers/tests/edge/cli/test_edge_command.py 
b/providers/tests/edge/cli/test_edge_command.py
index acc6da1749..5014edea11 100644
--- a/providers/tests/edge/cli/test_edge_command.py
+++ b/providers/tests/edge/cli/test_edge_command.py
@@ -17,6 +17,7 @@
 from __future__ import annotations
 
 import logging
+import os
 from datetime import datetime
 from pathlib import Path
 from subprocess import Popen
@@ -37,12 +38,11 @@ pytest.importorskip("pydantic", minversion="2.0.0")
 
 
 def test_write_pid_to_pidfile_success(caplog, tmp_path):
-    caplog.set_level(logging.DEBUG)
-    pid_file_path = tmp_path / "file.pid"
-    _write_pid_to_pidfile(pid_file_path)
-    assert pid_file_path.exists()
-    assert "An existing PID file has been found" not in caplog.text
-    assert "PID file written to" in caplog.text
+    with caplog.at_level(logging.DEBUG):
+        pid_file_path = tmp_path / "file.pid"
+        _write_pid_to_pidfile(pid_file_path)
+        assert pid_file_path.exists()
+        assert "An existing PID file has been found" not in caplog.text
 
 
 def test_write_pid_to_pidfile_called_twice(tmp_path):
@@ -53,7 +53,7 @@ def test_write_pid_to_pidfile_called_twice(tmp_path):
     assert pid_file_path.exists()
 
 
-def test_write_pid_to_pidfile_created_by_other_instance(caplog, tmp_path):
+def test_write_pid_to_pidfile_created_by_other_instance(tmp_path):
     # write a PID file with the PID of this process
     pid_file_path = tmp_path / "file.pid"
     _write_pid_to_pidfile(pid_file_path)
@@ -63,14 +63,15 @@ def 
test_write_pid_to_pidfile_created_by_other_instance(caplog, tmp_path):
             _write_pid_to_pidfile(pid_file_path)
 
 
-def test_write_pid_to_pidfile_created_by_crashed_instance(caplog, tmp_path):
+def test_write_pid_to_pidfile_created_by_crashed_instance(tmp_path):
     # write a PID file with process ID 0
     with patch("os.getpid", return_value=0):
         pid_file_path = tmp_path / "file.pid"
         _write_pid_to_pidfile(pid_file_path)
-    # write a PID file with the current process ID
+        assert "0" == pid_file_path.read_text().strip()
+    # write a PID file with the current process ID, call should not raise an 
exception
     _write_pid_to_pidfile(pid_file_path)
-    assert "PID file is orphaned." in caplog.text
+    assert str(os.getpid()) == pid_file_path.read_text().strip()
 
 
 # Ignore the following error for mocking

Reply via email to