I would like to propose two changes to CLIRunner.isolated_filesystem, which I believe would significantly improve the experience of debugging tests using it:
- Add an argument that allows users to specify the temporary directory.
- Add an argument indicating that the temporary directory shouldn't be deleted (if an exception occurs).
The current behavior of isolated_filesystem of creating a random temporary directory without allowing specifying a specific directory or even a (partial) name and deleting it no matter what, makes it impossible to inspect the directory in case of test failures to gather more information. Even if the directory wouldn't be deleted, it's difficult to find.
By allowing the user to define a temporary directory, it's possible to take advantage of mechanisms such as py.test's tmpdir fixture or other systems to separate setup code from the actual test and to make the directory known to the user for inspection.
I would like to propose two changes to
CLIRunner.isolated_filesystem, which I believe would significantly improve the experience of debugging tests using it:The current behavior of
isolated_filesystemof creating a random temporary directory without allowing specifying a specific directory or even a (partial) name and deleting it no matter what, makes it impossible to inspect the directory in case of test failures to gather more information. Even if the directory wouldn't be deleted, it's difficult to find.By allowing the user to define a temporary directory, it's possible to take advantage of mechanisms such as py.test's
tmpdirfixture or other systems to separate setup code from the actual test and to make the directory known to the user for inspection.