@contextmanager
def assertNoFDsLeaked(test_case):
 gc.collect()
 def process_fds():
  path = FilePath('/dev/fd')
  if (not path.exists()):
   raise SkipTest('/dev/fd is not available.')
  return set([child.basename() for child in path.children()])
 fds = process_fds()
 try:
  (yield)
 finally:
  test_case.assertEqual(process_fds(), fds)

@ contextmanager def assertNoFDsLeaked ( test_case ) : gc . collect ( ) def process_fds ( ) : path = FilePath ( '/dev/fd' ) if ( not path . exists ( ) ) : raise SkipTest ( '/dev/fd is not available.' ) return set ( [ child . basename ( ) for child in path . children ( ) ] ) fds = process_fds ( ) try : ( yield ) finally : test_case . assertEqual ( process_fds ( ) , fds )
context manager that asserts no file descriptors are leaked .