From f824a731433fae6ae8c9c5538324a660cb11cbfe Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Tue, 1 Apr 2014 15:36:54 -0700 Subject: [PATCH] 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 --- testing/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index ebd5b1b6f..e91a64e89 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -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 = []