Fix erp5 interface post in Python 2
The e-mail messages are normalized in a way compatible with both Python 2 and Python 3.
In Python 2, the previous version added a unixfrom
, which contains the date, making the tests fail when there is a change of one second in the clock between generating the first and the second message.
Moreover, the second message contained a previous unixfrom
.
This has been solved by removing unixfrom
in the normalized string.
In Python 3, messages had an inconsistent folding, due to https://github.com/python/cpython/issues/72649 .
This has been solved by manual unfolding (using a regex substitution) and by outputing normalized strings without folding (setting maxheaderlen=0
, which means no maximum line lenght).
With these changes, the normalized string can be compared in both versions without problems.
In addition, some bare encode/decode calls were replaced by the appropriate methods.
Tests passed locally and a test suite is in progress.