From 8aa0809fbc9a91ec286ca02bd7f0b673e06905de Mon Sep 17 00:00:00 2001
From: Daniel Hahler <git@thequod.de>
Date: Sun, 27 Oct 2019 02:28:35 +0100
Subject: [PATCH] on_rm_rf_error: ignore os.open (no warning)

Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
---
 src/_pytest/pathlib.py | 11 ++++++-----
 testing/test_tmpdir.py |  7 +++++++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py
index 543103fb5..bd76fac6b 100644
--- a/src/_pytest/pathlib.py
+++ b/src/_pytest/pathlib.py
@@ -68,13 +68,14 @@ def on_rm_rf_error(func, path: str, exc, *, start_path: Path) -> bool:
         return False
 
     if func not in (os.rmdir, os.remove, os.unlink):
-        warnings.warn(
-            PytestWarning(
-                "(rm_rf) unknown function {} when removing {}:\n{}: {}".format(
-                    path, func, exctype, excvalue
+        if func not in (os.open,):
+            warnings.warn(
+                PytestWarning(
+                    "(rm_rf) unknown function {} when removing {}:\n{}: {}".format(
+                        path, func, exctype, excvalue
+                    )
                 )
             )
-        )
         return False
 
     # Chmod + retry.
diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py
index 0ebed22ac..2433d6145 100644
--- a/testing/test_tmpdir.py
+++ b/testing/test_tmpdir.py
@@ -393,6 +393,13 @@ class TestRmRf:
             on_rm_rf_error(None, str(fn), exc_info, start_path=tmp_path)
             assert fn.is_file()
 
+        # ignored function
+        with pytest.warns(None) as warninfo:
+            exc_info = (None, PermissionError(), None)
+            on_rm_rf_error(os.open, str(fn), exc_info, start_path=tmp_path)
+            assert fn.is_file()
+        assert not [x.message for x in warninfo]
+
         exc_info = (None, PermissionError(), None)
         on_rm_rf_error(os.unlink, str(fn), exc_info, start_path=tmp_path)
         assert not fn.is_file()