ideally, there would be a version of this that mock.path's os.open to throw a OSError would be good too (to simulate a fail of O_EXCL constraint)

But...

mocking os.open is a PITA  (see http://mapleoin.eu/perma/mocking-python-file-open)

so reading/writing to temp probably okay here