From 60f9dc7a54595e9a3f3c6f007e8de3d59305754e Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Wed, 19 Mar 2014 04:18:04 +0600 Subject: [PATCH] TST fix file descriptor leak and a bad variable name in get_testlog --- scrapy/utils/test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scrapy/utils/test.py b/scrapy/utils/test.py index 6106976b1..8c1f7fe8a 100644 --- a/scrapy/utils/test.py +++ b/scrapy/utils/test.py @@ -53,11 +53,13 @@ def get_testenv(): def get_testlog(): """Get Scrapy log of current test, ignoring the rest""" + with open("test.log", "rb") as fp: + loglines = fp.readlines() + thistest = [] - loglines = open("test.log").readlines() - for l in loglines[::-1]: - thistest.append(l) - if "[-] -->" in l: + for line in loglines[::-1]: + thistest.append(line) + if "[-] -->" in line: break return "".join(thistest[::-1])