Repository navigation
Handle utils test warnings - #9569
Conversation
|
I can't speak for the timer stuff but the rest should probably be turned into explicit checks that appropriate warnings are raised by specific lines. If the cache is readonly, for example, we want to confirm that operations that would normally write to it raise a relevant warning, and operations that only require reading don't warn. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
|
|
||
| class TestCStack(): | ||
| class TestDStack(): |
| assert not is_url_in_cache(nonexistent) | ||
|
|
||
|
|
||
| @pytest.mark.filterwarnings('ignore:Not clearing data cache - cache inaccessible due to FileNotFoundError') |
There was a problem hiding this comment.
I get no warnings on my machine, at least, though it's not tested in CI. No reason this should emit a warning - clear_download_cache should work fine (no warnings) on a nonexistent cache, and it shouldn't be running on a nonexistent cache here anyway. But if you can produce a warning, let me know and I'll try to track it down?
|
@aarchiba , here is what I get when running the test on my machine locally with |
c0ab82d to
798a8ef
Compare
|
|
||
| zip_file_name = os.path.join(tmpdir, "the.zip") | ||
| clear_download_cache() | ||
| with pytest.warns(CacheMissingWarning, match='Not clearing data cache - ' |
There was a problem hiding this comment.
@aarchiba , I made it much more explicit now. So if indeed it is just my machine acting weird, the jobs would fail in CI.
There was a problem hiding this comment.
This is still likely to be trouble - it will fail on any machine (like mine) that doesn't emit the warning. There's a filterwarnings context manager that would succeed in ignoring the warning but I think it's better to prevent the warning being emitted - it is fine if clear_download_cache() is called when no cache exists, and we shouldn't be emitting warnings.
Wait. I think what's going on is maybe that the shelve is opened, then the on-disk file is deleted, then the shelve is closed, and this backend doesn't like that. Which is not unreasonable. But I can catch that exception and let it go without a warning, because this only happens with a no-argument clear_download_cache().
|
This is weird, seems like that warning is not emitted in CircleCI 32-bit job and Travis CI Python 3.8 job, but the other Travis CI jobs are seemed to catch it. (The other CircleCI jobs are irrelevant here.) |
|
There is some difference based on which dbm backend is used by shelve - gdbm versus dbm versus dumb.py. It might be possible to force all machines everywhere to use dumb.py, which would resolve certain problems - for example if your astropy installation creates a gdbm cache index but then you try to run astropy in conda, which doesn't provide gdbm, astropy will choke. This would have the side effect of making the shelve behaviour much more uniform (but also slower - though I'm not sure speed is much of a concern for the cache). I can also poke around and try to ensure the warning is not emitted when it's not necessary (the case here) but it'll be tricky unless I can arrange to control the database backend (I have ideas). I guess I should create an issue about database format. |
for a future PR. Remove unused import.
0408da2 to
1fa9e0c
Compare
|
I cancelled the rest of CircleCI tests, as they are unnecessary and the queue is too long. |
Description
This pull request is to address test warnings emitted by
utils. @aarchiba should have a look as she added most of these tests in #9182.This is a part of #7928