Skip to content

test_binascii.test_b2a_qp_a2b_qp_round_trip flaky #127697

@colesbury

Description

@colesbury

The hypothesis test test_b2a_qp_a2b_qp_round_trip checks that binascii.a2b_qp(binascii.b2a_qp(<value>)) gives the original value. However, this is not always true when istext=True (the default) and the value contains a mix of \n and \r\n new lines.

import binascii
>>>binascii.b2a_qp(b'\n\r\n', istext=True)
b'\n\n'
>>> binascii.a2b_qp(b'\n\n')
b'\n\n'

@hypothesis.given(
binary=hypothesis.strategies.binary(),
quotetabs=hypothesis.strategies.booleans(),
istext=hypothesis.strategies.booleans(),
header=hypothesis.strategies.booleans(),
)
def test_b2a_qp_a2b_qp_round_trip(self, binary, quotetabs, istext, header):
converted = binascii.b2a_qp(
self.type2test(binary),
quotetabs=quotetabs, istext=istext, header=header,
)
restored = binascii.a2b_qp(self.type2test(converted), header=header)
self.assertConversion(binary, converted, restored,
quotetabs=quotetabs, istext=istext, header=header)

See also #64320

Seen in https://github.com/python/cpython/actions/runs/12200589926/job/34037087571

cc @sobolevn @picnixz

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions