code: def test_poll_unit_tests(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))
  
      with open(TESTFN, "w") as f:
          fd = f.fileno()
          p = select.poll()
          p.register(f)
          r = p.poll()
          self.assertEqual(r[0][0], fd)
      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)
  
file_path: cpython/Lib/test/test_poll.py
imports: import os
  import subprocess
  import random
  import select
  import threading
  import time
  import unittest
  from test.support import cpython_only, requires_subprocess, requires_working_socket, requires_resource
  from test.support import threading_helper
  from test.support.os_helper import TESTFN
label_desc: Use image node_id 2 for calling the PollTests obj's underlying member method code with example usage: obj.test_poll_unit_tests() and returns: str