<commit_before>from itertools import product

import pytest

from .. import ( tuple, archive )


@pytest.mark.parametrize('position', ['left', 'right'])
def test_position(position):
    key = (1, 2, 3)
    class t:
        @staticmethod
        def to_path(_):
            return key
    a = archive(transformer = t, date_format = 'DATE', position = position)
    observed = a.to_path(key)
    if position == 'left':
        assert observed[0] == 'DATE'
        assert observed[1:] == key
    elif position == 'right':
        assert observed[-1] == 'DATE'
        assert observed[:-1] == key
    else:
        raise AssertionError('My test is broken.')

def test_from_path():
    'from_path should be the same as normal.'
    class t:
        @staticmethod
        def from_path(_):
            return 'abc'
    a = archive(transformer = t)
    assert a.from_path(('one', 'two', 'three', 'four')) == 'abc'

testcases_attrs = product(['binary_mode', 'cache_exceptions'],
                          [None, True, False])
@pytest.mark.parametrize('attr, attr_value', testcases_attrs)
def test_attrs():
    'binary_mode and cache_exceptions should be passed properly.'
    t = object()
    if attr_value != None:
        setattr(t, attr, attr_value)
    a = archive(transformer = t)

    if attr_value == None:
        assert not hasattr(a, attr)
    else:
        assert getattr(a, attr) == attr_value

<EMAIL>('position, transformer, key', testcases_position):<commit_msg>more test<commit_after>from itertools import product

import pytest

from .. import ( tuple, archive )


@pytest.mark.parametrize('position', ['left', 'right'])
def test_position(position):
    key = (1, 2, 3)
    class t:
        @staticmethod
        def to_path(_):
            return key
    a = archive(transformer = t, date_format = 'DATE', position = position)
    observed = a.to_path(key)
    if position == 'left':
        assert observed[0] == 'DATE'
        assert observed[1:] == key
    elif position == 'right':
        assert observed[-1] == 'DATE'
        assert observed[:-1] == key
    else:
        raise AssertionError('My test is broken.')

def test_from_path():
    'from_path should be the same as normal.'
    class t:
        @staticmethod
        def from_path(_):
            return 'abc'
    a = archive(transformer = t)
    assert a.from_path(('one', 'two', 'three', 'four')) == 'abc'

testcases_attrs = product(['binary_mode', 'cache_exceptions'],
                          [None, True, False])
@pytest.mark.parametrize('attr, attr_value', testcases_attrs)
def test_attrs(attr, attr_value):
    'binary_mode and cache_exceptions should be passed properly.'
    class t:
        pass
    if attr_value != None:
        setattr(t, attr, attr_value)
    a = archive(transformer = t)

    if attr_value == None:
        assert not hasattr(a, attr)
    else:
        assert getattr(a, attr) == attr_value

<EMAIL>ize('position, transformer, key', testcases_position):
{'fraction_non_alphanumeric': 0.1299797434166104, 'fraction_numerical': 0.004726536124240378, 'mean_word_length': 2.764930114358323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '356059', 'n_tokens_mistral': 921, 'n_tokens_neox': 916, 'n_words': 260}