diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py index 5bf9587a6ca22..55256499c6bb2 100644 --- a/pandas/tests/io/parser/test_common.py +++ b/pandas/tests/io/parser/test_common.py @@ -974,6 +974,15 @@ def test_no_permission(all_parsers): msg = r"\[Errno 13\]" with tm.ensure_clean() as path: os.chmod(path, 0) # make file unreadable + + # verify that this process cannot open the file (not running as sudo) + try: + with open(path): + pass + pytest.skip("Running as sudo.") + except PermissionError: + pass + with pytest.raises(PermissionError, match=msg) as e: parser.read_csv(path) assert path == e.value.filename