title: assertIsInstance() against multiple class names
body: <p>I have a function which should set an object attribute to a PIL Image instance: </p>
  
  <pre><code>from PIL import Image
  
  class SimpleExample:
      def __init__(self):
          self.img = self.load_image()
  
      def load_image():
          self.img = Image.open(image)
  </code></pre>
  
  <p>To test the proper execution of load_image() I thought to use unittest.TestCase.assertIsInstance(), but introspection of the resultant instance gives a different <strong>class</strong>.<strong>name</strong> depending on the file type of the image that was loaded. I can't find anything along the lines of <em>assertIsInstanceFromModule()</em> in unittest, so this seems to be the assertion helper that best reflects what I am really trying to test.</p>
  
  <p>I have come up with a couple solutions but am not satisfied with either of them:</p>
  
  <p><strong>Use a loop</strong>
  Produce a list of all possible class names, iterate though list, test each member for equality, then assertIsInstance for the appropriate list member. This is awkward, unpythonic, and I'm certainly not very proud of it. It does however work, and it uses what I think is the most meaningful assertion.</p>
  
  <pre><code>simplified_names = ['JpegImageFile', 'PngImageFile']
  for i, name in enumerate(simplified_names):
      if SimpleExample.img.__class__.__name__ == name:
          TestCase.assertIsInstance(SimpleExample.img, simplified_names[i])
  </code></pre>
  
  <p><strong>Use a different assertion helper</strong>
  Produce a list of all possible class names and assert that the class name of the generated object is in that list. It works, it's simple, but I don't like what it is that I'm actually asserting here.</p>
  
  <pre><code>simplified_names = ['JpegImageFile', 'PngImageFile']
  TestCase.assertIn(SimpleExample.img.__class__.__name__, simplified_names)
  </code></pre>
  
  <p>Does anyone have any other idea about how to assert against multiple possible class names?
  Should I be approaching the test from a different direction and use a different assertion?
  This is my first foray into unittest. Should I go back to just testing my code with print?</p>
  
  <p>~~~~~
  And the obvious answer is...</p>
  
  <p>Test against parent class. Alternatively, I could have noticed that a better option was presented to me every time I saw the following error:</p>
  
  <pre><code>TypeError: isinstance() arg 2 must be a type or tuple of types
  </code></pre>
  
  <p>Emphasis on the "or tuple."</p>
  
  <p>Thanks for all the help Martijn Pieters.</p>