@@ -114,3 +114,4 @@ class Command(BaseCommand):
'errors': errors,
'new': count - duplicates - dropped - errors,
})
+ mbox.close()
@@ -52,6 +52,7 @@ class ParsemailTest(TestCase):
with self.assertRaises(SystemExit) as exc:
call_command('parsemail', infile=None)
+ sys.stdin.close()
self.assertEqual(exc.exception.code, 1)
def test_valid_path(self):
@@ -78,6 +79,7 @@ class ParsemailTest(TestCase):
call_command('parsemail', infile=None,
list_id=project.listid)
+ sys.stdin.close()
self.assertEqual(exc.exception.code, 0)
count = models.Patch.objects.filter(project=project.id).count()
@@ -54,6 +54,7 @@ class _BaseTestCase(TestCase):
results[1].append(obj)
else:
results[2].append(obj)
+ mbox.close()
self.assertParsed(results, counts)
@@ -601,6 +602,8 @@ class SeriesNameTestCase(TestCase):
self._parse_mail(mbox[2])
self.assertEqual(cover.latest_series.name, cover_name)
+ mbox.close()
+
def test_no_cover_letter(self):
"""Series without a cover letter.
@@ -621,6 +624,8 @@ class SeriesNameTestCase(TestCase):
self._parse_mail(mbox[1])
self.assertEqual(series.name, patch.name)
+ mbox.close()
+
def test_out_of_order(self):
"""Series received out of order.
@@ -645,6 +650,8 @@ class SeriesNameTestCase(TestCase):
cover = self._parse_mail(mbox[2])
self.assertEqual(cover.latest_series.name, self._format_name(cover))
+ mbox.close()
+
def test_custom_name(self):
"""Series with custom name.
@@ -673,3 +680,5 @@ class SeriesNameTestCase(TestCase):
self._parse_mail(mbox[2])
self.assertEqual(series.name, series_name)
+
+ mbox.close()
@@ -54,7 +54,9 @@ def read_patch(filename, encoding=None):
else:
f = open(file_path)
- return f.read()
+ result = f.read()
+ f.close()
+ return result
error_strings = {
This is just a matter of correctly closing files we open. Signed-off-by: Daniel Axtens <dja@axtens.net> --- patchwork/management/commands/parsearchive.py | 1 + patchwork/tests/test_management.py | 2 ++ patchwork/tests/test_series.py | 9 +++++++++ patchwork/tests/utils.py | 4 +++- 4 files changed, 15 insertions(+), 1 deletion(-)