Skip to content

Commit 0ba6a51

Browse files
committed
Add regression test
1 parent e7ea38e commit 0ba6a51

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎astropy/config/tests/test_configs.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ def test_func():
7474
assert not os.path.exists(temp_cache_dir)
7575

7676

77+
def test_set_temp_cache_resets_on_exception(tmpdir):
78+
"""Test for regression of bug #9704"""
79+
t = paths.get_cache_dir()
80+
a = tmpdir / 'a'
81+
with open(a, 'wt') as f:
82+
f.write("not a good cache\n")
83+
with pytest.raises(OSError):
84+
with paths.set_temp_cache(a):
85+
pass
86+
assert t == paths.get_cache_dir()
87+
88+
7789
def test_config_file():
7890
from astropy.config.configuration import get_config, reload_config
7991

0 commit comments

Comments
 (0)