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

import pytest

from elizabeth.exceptions import UnsupportedLocale
from elizabeth.utils import (
    pull, luhn_checksum,
    locale_information, download_image
)


def test_luhn_checksum():
    assert luhn_checksum("7992739871") == "3"


def test_pull():
    data = pull('personal.json', 'en')

    assert data['views_on'] is not None
    assert isinstance(data['views_on'], list)
    with pytest.raises(UnsupportedLocale):
        pull('personal.json', 'w')
    with pytest.raises(FileNotFoundError):
        pull('something.json', 'en')


def test_download_image():
    result = download_image(url=None)
    assert result is None

    verified = download_image(
        url="https://github.com/lk-geimfari/elizabeth/raw/master/other/elizabeth_1.png",
    )
    assert verified == "elizabeth_1.png"


def test_locale_information():
    result = locale_information(locale='ru')
    assert result == 'Russian'<commit_msg>clean up downloaded image after test<commit_after># -*- coding: utf-8 -*-

import os
import pytest

from elizabeth.exceptions import UnsupportedLocale
from elizabeth.utils import (
    pull, luhn_checksum,
    locale_information, download_image
)


def test_luhn_checksum():
    assert luhn_checksum("7992739871") == "3"


def test_pull():
    data = pull('personal.json', 'en')

    assert data['views_on'] is not None
    assert isinstance(data['views_on'], list)
    with pytest.raises(UnsupportedLocale):
        pull('personal.json', 'w')
    with pytest.raises(FileNotFoundError):
        pull('something.json', 'en')


def test_download_image():
    result = download_image(url=None)
    assert result is None

    verified = download_image(
        url="https://github.com/lk-geimfari/elizabeth/raw/master/other/elizabeth_1.png",
    )
    assert verified == "elizabeth_1.png"
    os.remove(verified)


def test_locale_information():
    result = locale_information(locale='ru')
    assert result == 'Russian'
{'fraction_non_alphanumeric': 0.12392513909964593, 'fraction_numerical': 0.014162873039959535, 'mean_word_length': 3.9203980099502487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7445065', 'n_tokens_mistral': 657, 'n_tokens_neox': 629, 'n_words': 133}