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

potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new 94bfbc8d6fb [v3-1-test] Use filelock to fix race condition in version 
suffix test for xdist runs (#58608) (#58616)
94bfbc8d6fb is described below

commit 94bfbc8d6fb856a75ade0256cc4a41810a47b41c
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Nov 24 11:34:35 2025 +0100

    [v3-1-test] Use filelock to fix race condition in version suffix test for 
xdist runs (#58608) (#58616)
    
    * Use filelock to fix race condition in version suffix test for xdist runs
    
    * Use filelock to fix race condition in version suffix test for xdist runs
    (cherry picked from commit 53ed24ffc76930f7d6760f9109e4c9b595a17f35)
    
    Co-authored-by: Amogh Desai <[email protected]>
---
 dev/breeze/tests/test_packages.py | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/dev/breeze/tests/test_packages.py 
b/dev/breeze/tests/test_packages.py
index 53e08050a74..df35db28945 100644
--- a/dev/breeze/tests/test_packages.py
+++ b/dev/breeze/tests/test_packages.py
@@ -397,22 +397,17 @@ AIRFLOWCTL_INIT_PY = AIRFLOW_ROOT_PATH / "airflow-ctl" / 
"src" / "airflowctl" /
 
 
 @pytest.fixture
-def restore_version_files():
-    # save contents of all version files before test starts
-    version_files = [
-        AIRFLOW_CORE_INIT_PY,
-        TASK_SDK_INIT_PY,
-        AIRFLOWCTL_INIT_PY,
-    ]
-    original_contents = {f: f.read_text() for f in version_files if f.exists()}
+def lock_version_files():
+    from filelock import FileLock
 
-    yield
-
-    # restore original contents after test
-    for fp, content in original_contents.items():
-        fp.write_text(content)
+    lock_file = AIRFLOW_ROOT_PATH / ".version_files.lock"
+    with FileLock(lock_file):
+        yield
+    if lock_file.exists():
+        lock_file.unlink()
 
 
[email protected]("lock_version_files")
 @pytest.mark.parametrize(
     ("distributions", "init_file_path", "version_suffix", 
"floored_version_suffix"),
     [
@@ -440,7 +435,6 @@ def restore_version_files():
     ],
 )
 def test_apply_version_suffix_to_non_provider_pyproject_tomls(
-    restore_version_files,
     distributions: tuple[str, ...],
     init_file_path: Path,
     version_suffix: str,

Reply via email to