Re: [PATCH] Remove ResourceWarnings under Py3
On Wed, 2017-06-28 at 17:35 +1000, Andrew Donnellan wrote: > On 28/06/17 16:55, Daniel Axtens wrote: > > This is just a matter of correctly closing files we open. > > > > Signed-off-by: Daniel Axtens> > Reviewed-by: Andrew Donnellan Aye, looks good to me too. Reviewed-by: Stephen Finucane ...and applied. Stephen ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
Re: [PATCH] Remove ResourceWarnings under Py3
On 28/06/17 16:55, Daniel Axtens wrote: This is just a matter of correctly closing files we open. Signed-off-by: Daniel AxtensReviewed-by: Andrew Donnellan --- 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(-) diff --git a/patchwork/management/commands/parsearchive.py b/patchwork/management/commands/parsearchive.py index a3c8360186c8..4e102a988e76 100644 --- a/patchwork/management/commands/parsearchive.py +++ b/patchwork/management/commands/parsearchive.py @@ -114,3 +114,4 @@ class Command(BaseCommand): 'errors': errors, 'new': count - duplicates - dropped - errors, }) +mbox.close() diff --git a/patchwork/tests/test_management.py b/patchwork/tests/test_management.py index f9166739986b..f548fce3b8e5 100644 --- a/patchwork/tests/test_management.py +++ b/patchwork/tests/test_management.py @@ -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() diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py index 181fc6d2ac1c..53b5c63e8fa9 100644 --- a/patchwork/tests/test_series.py +++ b/patchwork/tests/test_series.py @@ -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() diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py index 3d0293cab36b..d4005c7729e8 100644 --- a/patchwork/tests/utils.py +++ b/patchwork/tests/utils.py @@ -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 = { -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnel...@au1.ibm.com IBM Australia Limited ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork
[PATCH] Remove ResourceWarnings under Py3
This is just a matter of correctly closing files we open. Signed-off-by: Daniel Axtens--- 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(-) diff --git a/patchwork/management/commands/parsearchive.py b/patchwork/management/commands/parsearchive.py index a3c8360186c8..4e102a988e76 100644 --- a/patchwork/management/commands/parsearchive.py +++ b/patchwork/management/commands/parsearchive.py @@ -114,3 +114,4 @@ class Command(BaseCommand): 'errors': errors, 'new': count - duplicates - dropped - errors, }) +mbox.close() diff --git a/patchwork/tests/test_management.py b/patchwork/tests/test_management.py index f9166739986b..f548fce3b8e5 100644 --- a/patchwork/tests/test_management.py +++ b/patchwork/tests/test_management.py @@ -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() diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py index 181fc6d2ac1c..53b5c63e8fa9 100644 --- a/patchwork/tests/test_series.py +++ b/patchwork/tests/test_series.py @@ -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() diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py index 3d0293cab36b..d4005c7729e8 100644 --- a/patchwork/tests/utils.py +++ b/patchwork/tests/utils.py @@ -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 = { -- 2.11.0 ___ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork