view test/test_mailer.py @ 8215:1b15f635ada1

fix(web) issue2551382 - handle crash in request call in test due to invalid utf8 with surrogate. Ci reports this failure in the requests call from the test case: > string = string.encode(encoding, errors) E UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 48: surrogates not allowed E Falsifying example: test_class_url_param_accepting_integer_values( E self=<test.test_liveserver.FuzzGetUrls testMethod=test_class_url_param_accepting_integer_values>, E param='@verbose', # or any other generated value E value='\ud800', E ) E Explanation: E These lines were always and only run by failing examples: E /opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/site-packages/requests/utils.py:675 E E You can reproduce this example by temporarily adding @reproduce_failure('6.122.3', b'AAAAAQDXAA==') as a decorator on your test case
author John Rouillard <rouilj@ieee.org>
date Mon, 16 Dec 2024 19:19:07 -0500
parents 95a366d46065
children
line wrap: on
line source

#-*- encoding: utf-8 -*-
import unittest

from roundup import mailer

class EncodingTestCase(unittest.TestCase):
    def testEncoding(self):
        a = lambda n, a, c, o: self.assertEqual(mailer.nice_sender_header(n,
            a, c), o)
        a('ascii', 'ascii@test.com', 'iso8859-1', 'ascii <ascii@test.com>')
        a(u'café', 'ascii@test.com', 'iso8859-1',
            '=?iso8859-1?q?caf=E9?= <ascii@test.com>')
        a(u'café', 'ascii@test.com', 'utf-8',
            '=?utf-8?b?Y2Fmw6k=?= <ascii@test.com>')
        a('as"ii', 'ascii@test.com', 'iso8859-1', '"as\\"ii" <ascii@test.com>')

# vim: set et sts=4 sw=4 :

Roundup Issue Tracker: http://roundup-tracker.org/