old_contents: import os
  import urllib2
  
  from . import datasets
  
  
  class mock_urllib2(object):
  
      def __init__(self):
          """Object that mocks the urllib2 module to store downloaded filenames.
  
          `downloaded_files` is the list of the files whose download has been
          requested.
          """
          self.urls = []
  
      class HTTPError(urllib2.URLError):
          code = 404
  
      class URLError(urllib2.URLError):
          pass
  
      def urlopen(self, url):
          self.urls.append(url)
          return url
  
      def reset(self):
          self.urls = []
  
  
  def mock_chunk_read_(response, local_file, initial_size=0, chunk_size=8192,
                       report_hook=None):
      return
  
  
  def mock_uncompress_file(file, delete_archive=True):
      return
  
  
  def mock_get_dataset(dataset_name, file_names, data_dir=None, folder=None):
      """ Mock the original _get_dataset function
  
      For test prupose, this function act as a two pass function. During the
      first run (normally, the fetching function is checking if the dataset
      already exists), the function will throw an error and create the files
      to prepare the second pass. After this first call, any other call will
      succeed as the files have been created.
  
      This behavior is made to force downloading of the dataset.
      """
      data_dir = datasets._get_dataset_dir(dataset_name, data_dir=data_dir)
      if not (folder is None):
          data_dir = os.path.join(data_dir, folder)
      file_paths = []
      error = None
      for file_name in file_names:
          full_name = os.path.join(data_dir, file_name)
          if not os.path.exists(full_name):
              error = IOError("No such file: '%s'" % full_name)
              dirname = os.path.dirname(full_name)
              if not os.path.exists(dirname):
                  os.makedirs(dirname)
              open(full_name, 'w').close()
          file_paths.append(full_name)
      if error is not None:
          raise error
      return file_paths
  
new_contents: import os
  import urllib2
  
  from . import datasets
  
  
  class mock_urllib2(object):
  
      def __init__(self):
          """Object that mocks the urllib2 module to store downloaded filenames.
  
          `downloaded_files` is the list of the files whose download has been
          requested.
          """
          self.urls = []
  
      class HTTPError(urllib2.URLError):
          code = 404
  
      class URLError(urllib2.URLError):
          pass
  
      def urlopen(self, url):
          self.urls.append(url)
          return url
  
      def reset(self):
          self.urls = []
  
  
  def mock_chunk_read_(response, local_file, initial_size=0, chunk_size=8192,
                       report_hook=None, verbose=0):
      return
  
  
  def mock_chunk_read_raise_error_(response, local_file, initial_size=0,
                                   chunk_size=8192, report_hook=None,
                                   verbose=0):
      raise urllib2.HTTPError("url", 418, "I'm a teapot", None, None)
  
  
  def mock_uncompress_file(file, delete_archive=True):
      return
  
  
  def mock_get_dataset(dataset_name, file_names, data_dir=None, folder=None):
      """ Mock the original _get_dataset function
  
      For test prupose, this function act as a two pass function. During the
      first run (normally, the fetching function is checking if the dataset
      already exists), the function will throw an error and create the files
      to prepare the second pass. After this first call, any other call will
      succeed as the files have been created.
  
      This behavior is made to force downloading of the dataset.
      """
      data_dir = datasets._get_dataset_dir(dataset_name, data_dir=data_dir)
      if not (folder is None):
          data_dir = os.path.join(data_dir, folder)
      file_paths = []
      error = None
      for file_name in file_names:
          full_name = os.path.join(data_dir, file_name)
          if not os.path.exists(full_name):
              error = IOError("No such file: '%s'" % full_name)
              dirname = os.path.dirname(full_name)
              if not os.path.exists(dirname):
                  os.makedirs(dirname)
              open(full_name, 'w').close()
          file_paths.append(full_name)
      if error is not None:
          raise error
      return file_paths
  
subject: Add a mock_chunk_read function that raises an exception