[PATCH 6/6] parsemail tests: add test for mail with utf-8

Stephen Finucane stephenfinucane at hotmail.com
Mon Sep 26 01:16:00 AEST 2016


On 23 Sep 10:06, Daniel Axtens wrote:
> This is designed to ensure we don't have any more hiccups with
> decoding UTF-8 under arbitrary locales, which can occur under
> Python 3.
> 
> Signed-off-by: Daniel Axtens <dja at axtens.net>

I think this can be squashed into the previous patch, but otherwise:

Reviewed-by: Stephen Finucane <stephenfinucane at hotmail.com>

>  patchwork/tests/test_management.py | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/patchwork/tests/test_management.py b/patchwork/tests/test_management.py
> index 5f97aa76866f..4b49131a72c2 100644
> --- a/patchwork/tests/test_management.py
> +++ b/patchwork/tests/test_management.py
> @@ -81,3 +81,32 @@ class ParsemailTest(TestCase):
>  
>          count = models.Patch.objects.filter(project=project.id).count()
>          self.assertEqual(count, 1)
> +
> +    def test_utf8_path(self):
> +        project = utils.create_project()
> +        utils.create_state()
> +
> +        path = os.path.join(TEST_MAIL_DIR, '0013-with-utf8-body.mbox')
> +        with self.assertRaises(SystemExit) as exc:
> +            call_command('parsemail', infile=path, list_id=project.listid)
> +
> +        self.assertEqual(exc.exception.code, 0)
> +
> +        count = models.Patch.objects.filter(project=project.id).count()
> +        self.assertEqual(count, 1)
> +
> +    def test_utf8_stdin(self):
> +        project = utils.create_project()
> +        utils.create_state()
> +
> +        path = os.path.join(TEST_MAIL_DIR, '0013-with-utf8-body.mbox')
> +        sys.stdin.close()
> +        sys.stdin = open(path)

Yeah, this makes more sense.

> +        with self.assertRaises(SystemExit) as exc:
> +            call_command('parsemail', infile=None,
> +                         list_id=project.listid)
> +
> +        self.assertEqual(exc.exception.code, 0)
> +
> +        count = models.Patch.objects.filter(project=project.id).count()
> +        self.assertEqual(count, 1)
> -- 
> 2.7.4
> 


More information about the Patchwork mailing list