'Test handling of failures'

def test_errno(self):

    with open('/dev/null', 'r') as fd:
        err = errno.EBADF
        msg = ('\\[Errno    %d\\]    tee:    %s' % (err, os.strerror(err)))
        try:
            tee(fd, fd, 3, 0)
        except IOError as e:
            self.assertTrue(re.match(msg, str(e)))
        else:
            self.fail('Expected    IOError    was    not    raised')
    self.assertEqual(ctypes.get_errno(), 0)
