title: In python's unittest, how do I mock a fake folder with fake images inside?
body: <p>I am trying to create a unit test for a function that reads every image from a folder and saves them in a list. </p>
  
  <p>Here is a simplified version of the function: </p>
  
  <pre><code>def read_images(directory):
  
      image_paths = os.listdir(directory)
  
      images = []
      for im in image_paths:
          images.append(cv2.imread(os.path.join(directory, im)))
  
      return images
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/37159714/python-creating-a-mock-or-fake-directory-with-files-for-unittesting">This other question</a> brought me close to the solution, but in my case I want the fake files created to be images (basically, arrays) so I can read them with <code>cv2.imread</code>.</p>
  
  <p>My idea is not having to create any temporary folder and, of course, not having to connect with any external folder or database. Is this possible?</p>
  
  <p>Edit: to be clear, I'd like to not have to create temporary folders, nor temporary image files. I'd like to know if there is a way of telling the program: "<em>There is a folder here, and inside it there are some images/arrays with this shape</em>", but with actually not having to create anything in memory.</p>