def _test_fetch(url):
 tempdir = _TempDir()
 with ArgvSetter(disable_stderr=False):
  archive_name = op.join(tempdir, 'download_test')
  _fetch_file(url, archive_name, timeout=30.0, verbose=False, resume=False)
  assert_raises(Exception, _fetch_file, 'NOT_AN_ADDRESS', op.join(tempdir, 'test'), verbose=False)
  resume_name = op.join(tempdir, 'download_resume')
  with open((resume_name + '.part'), 'w'):
   os.utime((resume_name + '.part'), None)
  _fetch_file(url, resume_name, resume=True, timeout=30.0, verbose=False)
  assert_raises(ValueError, _fetch_file, url, archive_name, hash_='a', verbose=False)
  assert_raises(RuntimeError, _fetch_file, url, archive_name, hash_=('a' * 32), verbose=False)

def _test_fetch ( url ) : tempdir = _TempDir ( ) with ArgvSetter ( disable_stderr = False ) : archive_name = op . join ( tempdir , 'download_test' ) _fetch_file ( url , archive_name , timeout = 30.0 , verbose = False , resume = False ) assert_raises ( Exception , _fetch_file , 'NOT_AN_ADDRESS' , op . join ( tempdir , 'test' ) , verbose = False ) resume_name = op . join ( tempdir , 'download_resume' ) with open ( ( resume_name + '.part' ) , 'w' ) : os . utime ( ( resume_name + '.part' ) , None ) _fetch_file ( url , resume_name , resume = True , timeout = 30.0 , verbose = False ) assert_raises ( ValueError , _fetch_file , url , archive_name , hash_ = 'a' , verbose = False ) assert_raises ( RuntimeError , _fetch_file , url , archive_name , hash_ = ( 'a' * 32 ) , verbose = False )
helper to test url retrieval .