Uses of `pytest`'s `tmpdir` fixture should be replaced with `tmp_path`
See original GitHub issueDescription
Some of the tests involve writing data, and such data should not be stored permanently. pytest
has two fixtures that provide temporary directories for writing test data: the recommended tmp_path
, which uses pathlib.Path
from the Python standard library, and the legacy tmpdir
utilizing py.path
, a third party library. The following shell command reveals that many tests in astropy
still use tmpdir
:
git grep --files-with-matches tmpdir -- *tests*
All uses of tmpdir
should be replaced with tmp_path
, although not all sub-packages have to be updated in a single pull request.
Sub-packages to update
-
config
#13788 -
coordinates
#13797 -
cosmology
#13847 -
io.ascii
#13876 -
io.fits
https://github.com/astropy/astropy/pull/13879 -
io.misc
(but note thatio.misc.asdf
is deprecated so onlyio.misc.tests
is worth updating) #13878 -
io.registry
#13849 -
io.votable
#13850 -
modeling
#13799 -
nddata
#13807 -
samp
#13848 -
table
#13802 -
tests
#13800 -
time
#13801 -
utils
#13874 -
visualization
https://github.com/astropy/astropy/pull/13822 -
wcs
#13796
Issue Analytics
- State:
- Created a year ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
How to use temporary directories and files in tests
You can use the tmp_path fixture which will provide a temporary directory unique to the test invocation, created in the base temporary directory....
Read more >Creating a temporary directory in PyTest - python
You can use the tmpdir fixture which will provide a temporary directory unique to the test invocation, created in the base temporary directory....
Read more >Python: PyTest fixtures - temporary directory - tmpdir
PyTest has a rich set of Fixures, one of the, called tmpdir makes it easy to create a temporary diriectory for each test...
Read more >`tmp_path` and `tmpdir` doesn't share the same temporary ...
I expected that the fixtures will operate on the same directory. ... Replace tmpdir fixture with tmp_path in tests aio-libs/aiohttp#3551.
Read more >Using tmpdir and tmpdir_factory
The tmpdir and tmpdir_factory builtin fixtures are used to create a temporary file system directory before your test runs, and remove the directory...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, definitely save
io.fits
for last. Thanks! 😸This only affects the tests, so I don’t think change logs are needed.