on_rm_rf_error: ignore os.open (no warning)
Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
This commit is contained in:
parent
5be3a9b5ce
commit
8aa0809fbc
|
@ -68,6 +68,7 @@ def on_rm_rf_error(func, path: str, exc, *, start_path: Path) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if func not in (os.rmdir, os.remove, os.unlink):
|
if func not in (os.rmdir, os.remove, os.unlink):
|
||||||
|
if func not in (os.open,):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
PytestWarning(
|
PytestWarning(
|
||||||
"(rm_rf) unknown function {} when removing {}:\n{}: {}".format(
|
"(rm_rf) unknown function {} when removing {}:\n{}: {}".format(
|
||||||
|
|
|
@ -393,6 +393,13 @@ class TestRmRf:
|
||||||
on_rm_rf_error(None, str(fn), exc_info, start_path=tmp_path)
|
on_rm_rf_error(None, str(fn), exc_info, start_path=tmp_path)
|
||||||
assert fn.is_file()
|
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)
|
exc_info = (None, PermissionError(), None)
|
||||||
on_rm_rf_error(os.unlink, str(fn), exc_info, start_path=tmp_path)
|
on_rm_rf_error(os.unlink, str(fn), exc_info, start_path=tmp_path)
|
||||||
assert not fn.is_file()
|
assert not fn.is_file()
|
||||||
|
|
Loading…
Reference in New Issue