bpo-32667: Fix tests when $PATH contains a file (#5322)

Some tests failed when the PATH environment variable contained a path
to an existing file. Fix tests to ignore also NotADirectoryError, not
only FileNotFoundError and PermissionError.
2 files changed