<commit_before># -*- coding: utf-8 -*-

from __future__ import with_statement

import base64
import email
import unittest
import time
import re

from flask import Flask
from flask_mail import Mail, Message, BadHeaderError


class TestCase(unittest.TestCase):

    TESTING = True
    DEFAULT_MAIL_SENDER = "<EMAIL>"

    def setUp(self):
        self.app = Flask(__name__)
        self.app.config.from_object(self)
        self.assertTrue(self.app.testing)
        self.mail = Mail(self.app)
        self.ctx = self.app.test_request_context()
        self.ctx.push()

    def tearDown(self):
        self.ctx.pop()


class TestMessage(TestCase):

    def test_initialize(self):
        msg = Message(subject="subject",
                      recipients=["<EMAIL>"])
        self.assertEqual(msg.sender, "<EMAIL>")
        self.assertEqual(msg.recipients, ["<EMAIL>"])

    def test_recipients_properly_initialized(self):
        msg = Message(subject="subject")
        self.assertEqual(msg.recipients, [])
        msg2 = Message(subject="subject")
        msg2.add_recipient("<EMAIL>")
        self.assertEqual(len(msg2.recipients), 1)

    def test_sendto_properly_set(self):
        msg = Message(subject="subject", recipients=["<EMAIL>"],
                      cc=["<EMAIL>"], bcc=["<EMAIL>"])
        self.assertEqual(len(msg.send_to), 3)
        msg.add_recipient("<EMAIL>")
        self.assertEqual(len(msg.send_to), 3)

    def test_add_recipient(self):
        msg = Message("testing")
        msg.add_recipient("<EMAIL>")
        self.assertEqual(msg.recipients, ["<EMAIL>"])

    def test_sender_as_tuple(self):<commit_msg>More adjustments for older python versions<commit_after># -*- coding: utf-8 -*-

from __future__ import with_statement

import base64
import email
import unittest
import time
import re

from flask import Flask
from flask_mail import Mail, Message, BadHeaderError


class TestCase(unittest.TestCase):

    TESTING = True
    DEFAULT_MAIL_SENDER = "<EMAIL>"

    def setUp(self):
        self.app = Flask(__name__)
        self.app.config.from_object(self)
        self.assertTrue(self.app.testing)
        self.mail = Mail(self.app)
        self.ctx = self.app.test_request_context()
        self.ctx.push()

    def tearDown(self):
        self.ctx.pop()

    def assertIn(self, member, container, msg=None):
        if hasattr(unittest.TestCase, 'assertIn'):
            return unittest.TestCase.assertIn(self, member, container, msg)
        return self.assertTrue(member in container)

    def assertNotIn(self, member, container, msg=None):
        if hasattr(unittest.TestCase, 'assertNotIn'):
            return unittest.TestCase.assertNotIn(self, member, container, msg)
        return self.assertFalse(member in container)

    def assertIsNotNone(self, obj, msg=None):
        if hasattr(unittest.TestCase, 'assertIsNotNone'):
            return unittest.TestCase.assertIsNotNone(self, obj, msg)
        return self.assertTrue(obj is not None)


class TestMessage(TestCase):

    def test_initialize(self):
        msg = Message(subject="subject",
                      recipients=["<EMAIL>"])
        self.assertEqual(msg.sender, "<EMAIL>")
        self.assertEqual(msg.recipients, ["<EMAIL>"])

    def test_recipients_properly_initialized(self):
        msg = Message(subject="subject")
        self.assertEqual(msg.recipients, [])
        msg2 = Message(subject="subject")
        msg2.add_recipient("<EMAIL>")
        self.assertEqual(len(msg2.recipients), 1)

    def test_sendto_properly_set(self):
        msg = Message(subject="subject", recipients=["<EMAIL>"],
                      cc=["<EMAIL>"], bcc=["<EMAIL>"])
        self.assertEqual(len(msg.send_to), 3)
        msg.add_recipient("<EMAIL>")
        self.assertEqual(len(msg.send_to), 3)

    def test_add_recipient(self):
        msg = Message("testing")
        msg.add_recipient("<EMAIL>")
        self.assertEqual(msg.recipients, ["<EMAIL>"])

    def test_sender_as_tuple(self):
{'fraction_non_alphanumeric': 0.12878977699824606, 'fraction_numerical': 0.0045101478326234025, 'mean_word_length': 3.0364004044489383, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '1229841', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1205, 'n_words': 232}