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

import os

from sigal.image import generate_image, generate_thumbnail

CURRENT_DIR = os.path.dirname(__file__)
TEST_IMAGE = 'exo20101028-b-full.jpg'


def test_image(tmpdir):
    "Test the Image class."

    srcfile = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir2',
                           TEST_IMAGE)
    dstfile = str(tmpdir.join(TEST_IMAGE))

    generate_thumbnail(srcfile, dstfile, (200, 150), None)
    assert os.path.isfile(dstfile)<commit_msg>More tests<commit_after># -*- coding:utf-8 -*-

import os
import pytest
from PIL import Image

from sigal import init_logging
from sigal.image import generate_image, generate_thumbnail

CURRENT_DIR = os.path.dirname(__file__)
TEST_IMAGE = 'exo20101028-b-full.jpg'
SRCFILE = os.path.join(CURRENT_DIR, 'sample', 'pictures', 'dir2', TEST_IMAGE)


def test_generate_image(tmpdir):
    "Test the generate_image function."

    dstfile = str(tmpdir.join(TEST_IMAGE))
    for size in [(600, 600), (300, 200)]:
        generate_image(SRCFILE, dstfile, size, None, method='ResizeToFill')
        im = Image.open(dstfile)
        assert im.size == size


def test_generate_image_processor(tmpdir):
    "Test generate_image with a wrong processor name."

    init_logging()
    dstfile = str(tmpdir.join(TEST_IMAGE))
    with pytest.raises(SystemExit):
        generate_image(SRCFILE, dstfile, (200, 200), None,
                       method='WrongMethod')


def test_generate_thumbnail(tmpdir):
    "Test the generate_thumbnail function."

    dstfile = str(tmpdir.join(TEST_IMAGE))
    for size in [(200, 150), (150, 200)]:
        generate_thumbnail(SRCFILE, dstfile, size, None)
        im = Image.open(dstfile)
        assert im.size == size

    for size, thumb_size in [((200, 150), (185, 150)),
                             ((150, 200), (150, 122))]:
        generate_thumbnail(SRCFILE, dstfile, size, None, fit=False)
        im = Image.open(dstfile)
        assert im.size == thumb_size
{'fraction_non_alphanumeric': 0.12235649546827794, 'fraction_numerical': 0.04028197381671702, 'mean_word_length': 3.3195652173913044, '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': '1262701', 'n_tokens_mistral': 711, 'n_tokens_neox': 637, 'n_words': 154}