diff --git a/scrapy/tests/test_commands.py b/scrapy/tests/test_commands.py index 08b8fc265..f7710f03b 100644 --- a/scrapy/tests/test_commands.py +++ b/scrapy/tests/test_commands.py @@ -26,10 +26,10 @@ class ProjectTest(unittest.TestCase): rmtree(self.temp_path) def call(self, *new_args, **kwargs): - out = tempfile.TemporaryFile() - args = (sys.executable, '-m', 'scrapy.cmdline') + new_args - return subprocess.call(args, stdout=out, stderr=out, cwd=self.cwd, \ - env=self.env, **kwargs) + with tempfile.TemporaryFile() as out: + args = (sys.executable, '-m', 'scrapy.cmdline') + new_args + return subprocess.call(args, stdout=out, stderr=out, cwd=self.cwd, + env=self.env, **kwargs) def proc(self, *new_args, **kwargs): args = (sys.executable, '-m', 'scrapy.cmdline') + new_args