<commit_before>"""Alt tool tests
"""

import rarfile


def install_unar_tool():
    rarfile.tool_setup(unrar=False, unar=True, bsdtar=False, force=True)

def install_bsdtar_tool():
    rarfile.tool_setup(unrar=False, unar=False, bsdtar=True, force=True)

def uninstall_alt_tool():
    rarfile.tool_setup(force=True)

def test_read_rar3():
    with rarfile.RarFile('test/files/seektest.rar') as rf:
        for fn in rf.namelist():
            rf.read(fn)

def test_read_rar3_old():
    with rarfile.RarFile('test/files/rar3-old.rar') as rf:
        for fn in rf.namelist():
            rf.read(fn)

def test_unar_tool():
    install_unar_tool()
    try:
        test_read_rar3()
        test_read_rar3_old()
    finally:
        uninstall_alt_tool()

def test_bsdtar_tool():
    install_bsdtar_tool()
    try:
        with rarfile.RarFile('test/files/rar3-old.rar') as rf:
            for fn in rf.namelist():
                rf.read(fn)
    finally:
        uninstall_alt_tool()

<commit_msg>test: disable unar on windows<commit_after>"""Alt tool tests
"""

import sys

import pytest

import rarfile


def install_unar_tool():
    rarfile.tool_setup(unrar=False, unar=True, bsdtar=False, force=True)

def install_bsdtar_tool():
    rarfile.tool_setup(unrar=False, unar=False, bsdtar=True, force=True)

def uninstall_alt_tool():
    rarfile.tool_setup(force=True)

def test_read_rar3():
    with rarfile.RarFile('test/files/seektest.rar') as rf:
        for fn in rf.namelist():
            rf.read(fn)

def test_read_rar3_old():
    with rarfile.RarFile('test/files/rar3-old.rar') as rf:
        for fn in rf.namelist():
            rf.read(fn)


@pytest.mark.skipif(sys.platform=="win32", reason="unar not available on Windows")
def test_unar_tool():
    install_unar_tool()
    try:
        test_read_rar3()
        test_read_rar3_old()
    finally:
        uninstall_alt_tool()

def test_bsdtar_tool():
    install_bsdtar_tool()
    try:
        with rarfile.RarFile('test/files/rar3-old.rar') as rf:
            for fn in rf.namelist():
                rf.read(fn)
    finally:
        uninstall_alt_tool()


{'fraction_non_alphanumeric': 0.12068149550402271, 'fraction_numerical': 0.006625650733554188, 'mean_word_length': 3.0420650095602295, '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': '5066022', 'n_tokens_mistral': 813, 'n_tokens_neox': 793, 'n_words': 144}