-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Milestone
Description
I pushed the upstream master to my staging branch on Jenkins, and I am getting the following failures:
_______________________________ test_url_nocache _______________________________
@remote_data
def test_url_nocache():
from ..data import get_readable_fileobj
with get_readable_fileobj(TESTURL, cache=False) as googlepage:
> assert googlepage.read().find('oogle</title>') > -1
E TypeError: read() should return bytes
astropy\utils\tests\test_data.py:44: TypeError
------------------------------- Captured stdout --------------------------------
Downloading http://www.google.com/index.html [Done]
______________________________ test_find_by_hash _______________________________
@remote_data
def test_find_by_hash():
from ..data import get_readable_fileobj, get_pkg_data_filename, clear_download_cache
import hashlib
with get_readable_fileobj(TESTURL, cache=True) as googlepage:
> hash = hashlib.md5(googlepage.read())
E TypeError: read() should return bytes
astropy\utils\tests\test_data.py:54: TypeError
------------------------------- Captured stdout --------------------------------
Downloading http://www.google.com/index.html [Done]
_________________________ test_data_noastropy_fallback _________________________
monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x051E17F0>
recwarn = <_pytest.recwarn.WarningsRecorder object at 0x051E1850>
@remote_data
def test_data_noastropy_fallback(monkeypatch, recwarn):
"""
Tests to make sure the default behavior when the cache directory can't
be located is correct
"""
from pytest import raises
from .. import data
from ...config import paths
# needed for testing the *real* lock at the end
lockdir = os.path.join(_get_download_cache_locs()[0], 'lock')
#better yet, set the configuration to make sure the temp files are deleted
data.DELETE_TEMPORARY_DOWNLOADS_AT_EXIT.set(True)
#make sure the config and cache directories are not searched
monkeypatch.setenv('XDG_CONFIG_HOME', 'foo')
monkeypatch.delenv('XDG_CONFIG_HOME')
monkeypatch.setenv('XDG_CACHE_HOME', 'bar')
monkeypatch.delenv('XDG_CACHE_HOME')
# make sure the _find_or_create_astropy_dir function fails as though the
# astropy dir could not be accessed
def osraiser(dirnm, linkto):
raise OSError
monkeypatch.setattr(paths, '_find_or_create_astropy_dir', osraiser)
with raises(OSError):
#make sure the config dir search fails
paths.get_cache_dir()
#first try with cache
fnout = data.download_file(TESTURL, cache=True)
assert os.path.isfile(fnout)
assert len(recwarn.list) > 1
w1 = recwarn.pop()
w2 = recwarn.pop()
assert w1.category == data.CacheMissingWarning
assert 'Remote data cache could not be accessed' in w1.message.args[0]
assert w2.category == data.CacheMissingWarning
assert 'File downloaded to temporary location' in w2.message.args[0]
assert fnout == w2.message.args[1]
#clearing the cache should be a no-up that doesn't affect fnout
data.clear_download_cache(TESTURL)
assert os.path.isfile(fnout)
#now remove it so tests don't clutter up the temp dir
#this should get called at exit, anyway, but we do it here just to make
#sure it's working correctly
data._deltemps()
assert not os.path.isfile(fnout)
assert len(recwarn.list) > 0
w3 = recwarn.pop()
assert w3.category == data.CacheMissingWarning
assert 'Not clearing data cache - cache inacessable' in str(w3.message)
#now try with no cache
fnnocache = data.download_file(TESTURL, cache=False)
with open(fnnocache) as googlepage:
> assert googlepage.read().decode().find('oogle</title>') > -1
E AttributeError: 'str' object has no attribute 'decode'
astropy\utils\tests\test_data.py:202: AttributeError
------------------------------- Captured stdout --------------------------------
@mdboom @iguananaut - if you have any ideas, let me know. Otherwise, I'll look into it once I get a chance, at the weekend.
Metadata
Metadata
Assignees
Labels
No labels