def METHOD_NAME(self):
    # returns NVAL for invalid file descriptor
    FD, w = os.pipe()
    os.close(FD)
    os.close(w)
    p = select.poll()
    p.register(FD)
    r = p.poll()
    self.assertEqual(r[0], (FD, select.POLLNVAL))
    f = open(TESTFN, 'w')
    fd = f.fileno()
    p = select.poll()
    p.register(f)
    r = p.poll()
    self.assertEqual(r[0][0], fd)
    f.close()
    r = p.poll()
    self.assertEqual(r[0], (fd, select.POLLNVAL))
    os.unlink(TESTFN)
    # type error for invalid arguments
    p = select.poll()
    self.assertRaises(TypeError, p.register, p)
    self.assertRaises(TypeError, p.unregister, p)
    # can't unregister non-existent object
    p = select.poll()
    self.assertRaises(KeyError, p.unregister, 3)
    # Test error cases
    pollster = select.poll()
    class Nope:
        pass
    class Almost:
        def fileno(self):
            return 'fileno'
    self.assertRaises(TypeError, pollster.register, Nope(), 0)
    self.assertRaises(TypeError, pollster.register, Almost(), 0)