def test_get_readable_fileobj_cleans_up_temporary_files(tmpdir, monkeypatch):
 local_filename = get_pkg_data_filename(os.path.join(u'data', u'local.dat'))
 url = (u'file://' + urllib.request.pathname2url(local_filename))
 monkeypatch.setattr(tempfile, u'tempdir', str(tmpdir))
 with get_readable_fileobj(url) as fileobj:
  pass
 tempdir_listing = tmpdir.listdir()
 assert (len(tempdir_listing) == 0)

def test_get_readable_fileobj_cleans_up_temporary_files ( tmpdir , monkeypatch ) : local_filename = get_pkg_data_filename ( os . path . join ( u'data' , u'local.dat' ) ) url = ( u'file://' + urllib . request . pathname2url ( local_filename ) ) monkeypatch . setattr ( tempfile , u'tempdir' , str ( tmpdir ) ) with get_readable_fileobj ( url ) as fileobj : pass tempdir_listing = tmpdir . listdir ( ) assert ( len ( tempdir_listing ) == 0 )
checks that get_readable_fileobj leaves no temporary files behind .