Remove cast of fd to int and sorting

Casting of fd can break for non-numeric fd (e.g.: "rtd" on Linux) and isn't
necessary since we don't need to sort.

--HG--
branch : refactor_LsofFdLeakChecker
This commit is contained in:
Marc Abramowitz 2014-04-01 15:36:54 -07:00
parent e45a33f029
commit f824a73143
1 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class LsofFdLeakChecker(object):
for line in out.split("\n"):
if isopen(line):
fields = line.split('\0')
fd = int(fields[0][1:])
fd = fields[0][1:]
filename = fields[1][1:]
if filename.startswith('/'):
open_files.append((fd, filename))
@ -53,7 +53,7 @@ def pytest_runtest_setup(item):
def check_open_files(config):
lines2 = config._fd_leak_checker.get_open_files()
new_fds = sorted(set([t[0] for t in lines2]) - set([t[0] for t in config._openfiles]))
new_fds = set([t[0] for t in lines2]) - set([t[0] for t in config._openfiles])
open_files = [t for t in lines2 if t[0] in new_fds]
if open_files:
error = []