<commit_before>"""
Tests run against live mail providers.

These aren't generally run as part of the test suite.
"""
import os

import pytest

from aiosmtplib import SMTP, SMTPAuthenticationError, SMTPStatus


pytestmark = [
    pytest.mark.skipif(
        os.environ.get("TRAVIS") == "true",
        reason="No tests against real servers on TravisCI",
    ),
    pytest.mark.asyncio(forbid_global_loop=True),
]


async def test_starttls_gmail(event_loop):
    client = SMTP(hostname="smtp.gmail.com", port=587, loop=event_loop, use_tls=False)
    await client.connect()
    await client.ehlo()
    await client.starttls(validate_certs=False)
    response = await client.ehlo()

    assert response.code == SMTPStatus.completed
    assert "smtp.gmail.com at your service" in response.message
    with pytest.raises(SMTPAuthenticationError):
        await client.login("test", "test")


@pytest.mark.skip(reason="No support for UTF8 yet")
@pytest.mark.asyncio(forbid_global_loop=True)
async def test_qq_login(event_loop):
    client = SMTP(hostname="smtp.qq.com", port=587, loop=event_loop, use_tls=False)
    await client.connect()
    await client.ehlo()
    await client.starttls(validate_certs=False)

    with pytest.raises(SMTPAuthenticationError):
        await client.login("test", "test")
<commit_msg>added timeout for live tests.<commit_after>"""
Tests run against live mail providers.

These aren't generally run as part of the test suite.
"""
import os

import pytest

from aiosmtplib import SMTP, SMTPAuthenticationError, SMTPStatus


pytestmark = [
    pytest.mark.skipif(
        os.environ.get("TRAVIS") == "true",
        reason="No tests against real servers on TravisCI",
    ),
    pytest.mark.asyncio(forbid_global_loop=True),
]


async def test_starttls_gmail(event_loop):
    client = SMTP(hostname="smtp.gmail.com", port=587, loop=event_loop, use_tls=False)
    await client.connect(timeout=0.1)
    await client.ehlo()
    await client.starttls(validate_certs=False)
    response = await client.ehlo()

    assert response.code == SMTPStatus.completed
    assert "smtp.gmail.com at your service" in response.message
    with pytest.raises(SMTPAuthenticationError):
        await client.login("test", "test")


@pytest.mark.skip(reason="No support for UTF8 yet")
@pytest.mark.asyncio(forbid_global_loop=True)
async def test_qq_login(event_loop):
    client = SMTP(hostname="smtp.qq.com", port=587, loop=event_loop, use_tls=False)
    await client.connect(timeout=0.1)
    await client.ehlo()
    await client.starttls(validate_certs=False)

    with pytest.raises(SMTPAuthenticationError):
        await client.login("test", "test")

{'fraction_non_alphanumeric': 0.11332831325301204, 'fraction_numerical': 0.00677710843373494, 'mean_word_length': 4.335341365461847, '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': '3782880', 'n_tokens_mistral': 877, 'n_tokens_neox': 894, 'n_words': 196}