[Patchew-devel] [PATCH] tests: fix test_tags for Python < 3.6
Paolo Bonzini
pbonzini at redhat.com
Tue Nov 27 13:52:53 UTC 2018
On 27/11/18 14:08, Caio Carrara wrote:
> On Tue, Nov 27, 2018 at 01:45:34PM +0100, Paolo Bonzini wrote:
>> email.policy was added in 3.6. Do not use it unless available.
>
> According to Python documentation[1], email.policy is new in version
> 3.3. Isn't fair enough have compatibility with Python 3.3+?
>
> The documentation indicates that what have changed in 3.6 is the
> "default" message factory[2]. That seems not being touched by your
> patch.
Travis disagrees though: :(
File "/home/travis/build/patchew-project/patchew/tests/test_tags.py",
line 58, in test_mbox_with_8bit_tags
parser = email.parser.BytesParser(policy=email.policy.SMTP)
AttributeError: module 'email' has no attribute 'policy'
on all of 3.3, 3.4 and 3.5.
Paolo
> [1] - https://docs.python.org/3.3/library/email.policy.html
> [2] - https://docs.python.org/3.6/library/email.parser.html#email.parser.BytesParser
>
>>
>> Signed-off-by: Paolo Bonzini <pbonzini at redhat.com>
>> ---
>> tests/test_tags.py | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/test_tags.py b/tests/test_tags.py
>> index a49a660..9ced996 100755
>> --- a/tests/test_tags.py
>> +++ b/tests/test_tags.py
>> @@ -55,7 +55,11 @@ class ImportTest(PatchewTestCase):
>> self.cli_import("0028-tags-need-8bit-encoding.mbox.gz")
>> self.cli_logout()
>> mbox = self.client.get('/QEMU/20181126152836.25379-1-rkagan at virtuozzo.com/mbox')
>> - parser = email.parser.BytesParser(policy=email.policy.SMTP)
>> + try:
>> + import email.policy
>> + parser = email.parser.BytesParser(policy=email.policy.SMTP)
>> + except ModuleNotFoundError:
>> + parser = email.parser.BytesParser()
>> msg = parser.parsebytes(mbox.content)
>> payload = decode_payload(msg)
>> self.assertIn('SynICState *synic = get_synic(cs);', payload)
>> --
>> 2.19.1
>>
>> _______________________________________________
>> Patchew-devel mailing list
>> Patchew-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/patchew-devel
>
More information about the Patchew-devel
mailing list