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

def test_not_a_directory(self):

    fd = open(UPLOAD_TO, 'w')
    fd.close()
    try:
        self.obj.testfile.save('foo.txt', SimpleUploadedFile('foo.txt', 'x'))
    except IOError as err:
        self.assertEqual(err.args[0], ('%s    exists    and    is    not    a    directory.' % UPLOAD_TO))
    except:
        self.fail('IOError    not    raised')
