'The correct IOError is raised when the upload directory name exists but isn\'t a directory'

def test_not_a_directory(self):

    open(UPLOAD_TO, 'wb').close()
    self.addCleanup(os.remove, UPLOAD_TO)
    with self.assertRaises(IOError) as exc_info:
        with SimpleUploadedFile('foo.txt', 'x') as file:
            self.obj.testfile.save('foo.txt', file, save=False)
    self.assertEqual(exc_info.exception.args[0], ('%s    exists    and    is    not    a    directory.' % UPLOAD_TO))
