skypyproject / skypy

SkyPy: A package for modelling the Universe.
BSD 3-Clause "New" or "Revised" License
118 stars 38 forks source link

TST: Use tmp_path fixture for temporary files in unit tests #489

Closed rrjbca closed 3 years ago

rrjbca commented 3 years ago

Description

Use pytest tmp_path fixture in unit tests. Creates a temporary directory where temporary files can be written and handles cleanup automatically. Resolves #466

Checklist

rrjbca commented 3 years ago

However, I wonder whether unittest.mock is more suitable for mocking files, so we don't need to create temporary files or have empty yml files(?)

This PR is not mocking any files. It is implementing a more robust method (a temporary directory) to automatically handle the deletion of files created by the skypy script during testing. We don't want to mock those files; the fundamental purpose of these unit tests is to check that those files are created correctly. Mocking config files might be possible but is unrelated to the issue this PR is addressing and I don't see an obvious benefit?