hypothesis icon indicating copy to clipboard operation
hypothesis copied to clipboard

`PermissionError` when Hypothesis database dir path is not accessible

Open Stranger6667 opened this issue 2 years ago • 2 comments

After this change, checking for whether the given location is usable may lead to PermissionError, if the location has e.g. 0o222 permissions. Previously, os.path.exists did not raise an exception there. Found out about it downstream in Schemathesis - I guess that the expected behavior for the cases when the directory is not accessible is to work with an in-memory database, but it does not happen due to PermissionError

Stranger6667 avatar Oct 08 '23 15:10 Stranger6667

I also noted that it only affects Linux in Schemathesis's test suite

Stranger6667 avatar Oct 08 '23 16:10 Stranger6667

I guess we should wrap a try: ... / except OSError: return False around https://github.com/HypothesisWorks/hypothesis/blob/5278b7cf4815857c0147389107060a8bf340d256/hypothesis-python/src/hypothesis/database.py#L47-L50

...and add a test for this specific case on Linux, too. I'll fix that this week, if you don't beat me to it.

Zac-HD avatar Oct 08 '23 16:10 Zac-HD

I would like to take this on.

JonathanPlasse avatar Mar 15 '24 06:03 JonathanPlasse