In a perfect world, I would rather see no temp dir in play here and the pdb just with mocked read/write to assert on. We would lean on manual testing for the actual file write/read but this seems ok to me. In a strict sense unit tests shouldn't be writing files to disk. Not sure how hard this is or how nervous it would make you feel about the functionality but it's worth considering.