Ticket #4522: 0007-Address-review-from-exarkun.patch

File 0007-Address-review-from-exarkun.patch, 917 bytes (added by Carlos Valiente, 12 years ago)

Diff against svn://svn.twistedmatrix.com/svn/Twisted/branches/faster-close-fds-4522, revision 29557

  • twisted/internet/test/test_posixprocess.py

     
    4343        for f in sys.stdin, sys.stdout, sys.stderr:
    4444            self.assertIn(f.fileno(), openfds)
    4545
     46        # See http://twistedmatrix.com/trac/ticket/4522#comment:17
    4647        f = file(os.devnull)
    47         new_openfds = process._listOpenFDs()
    48         self.assertTrue(len(new_openfds) > len(openfds))
    49 
    50         f.close()
    51         new_openfds = process._listOpenFDs()
    52         self.assertEqual(len(new_openfds), len(openfds))
     48        fd = os.dup(f.fileno())
     49        try:
     50            f.close()
     51            self.assertIn(fd, process._listOpenFDs())
     52        finally:
     53            os.close(fd)
     54        self.assertNotIn(fd, process._listOpenFDs())