<commit_before>import quopri
from   daemail.message import DraftMessage

TEXT = 'àéîøü'

def test_quopri_text():
    msg = DraftMessage()
    msg.addtext(TEXT)
    blob = msg.compile()
    assert isinstance(blob, bytes)
    assert TEXT.encode('utf-8') not in blob
    assert quopri.encodestring(TEXT.encode('utf-8')) in blob

def test_quopri_multipart():
    msg = DraftMessage()
    msg.addtext(TEXT)
    msg.addmimeblob(b'\0\0\0\0', 'application/octet-stream', 'null.dat')
    blob = msg.compile()
    assert isinstance(blob, bytes)
    assert TEXT.encode('utf-8') not in blob
    assert quopri.encodestring(TEXT.encode('utf-8')) in blob<commit_msg>Make tests forwards-compatible with new email API<commit_after>from   base64          import b64encode
import quopri
from   daemail.message import DraftMessage

TEXT = 'àéîøü\n'
# Something in the email module implicitly adds a newline to the body text if
# one isn't present, so we need to include one here lest the base64 encodings
# not match up.
TEXT_ENC = TEXT.encode('utf-8')

def test_7bit_text():
    msg = DraftMessage()
    msg.addtext(TEXT)
    blob = msg.compile()
    assert isinstance(blob, bytes)
    assert TEXT_ENC not in blob
    assert quopri.encodestring(TEXT_ENC) in blob or b64encode(TEXT_ENC) in blob

def test_7bit_multipart():
    msg = DraftMessage()
    msg.addtext(TEXT)
    msg.addmimeblob(b'\0\0\0\0', 'application/octet-stream', 'null.dat')
    blob = msg.compile()
    assert isinstance(blob, bytes)
    assert TEXT_ENC not in blob
    assert quopri.encodestring(TEXT_ENC) in blob or b64encode(TEXT_ENC) in blob
{'fraction_non_alphanumeric': 0.10602258469259725, 'fraction_numerical': 0.015683814303638646, 'mean_word_length': 3.8333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2841725', 'n_tokens_mistral': 547, 'n_tokens_neox': 529, 'n_words': 148}