<commit_before>from __future__ import unicode_literals

import wer


def test_main():
    assert wer


def test_loading_from_string():
    xml_string = b"""<?xml version="1.0" encoding="UTF-8"?>
        <WERREPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <MACHINEINFO machinename="client-machine.corp.cliendomain.com" os="6.1.6561.2.0.0.256.1"
        lcid="1033"/>
        <USERINFO username="Username"/>
        <APPLICATIONINFO appname="WER GPF Test Utility" apppath="E:\tools\GPFMe.exe" appcompany="Test
        Corporation"/>
        <EVENTINFO reporttype="2" eventtime="128496925196486378" eventtype="APPCRASH"
        friendlyeventname="Stopped working"/>
        <SIGNATURE>
        <PARAMETER id="0" name="Application Name" value="GPFMe.exe"/>
        <PARAMETER id="1" name="Application Version" value="6.0.4082.0"/>
        <PARAMETER id="2" name="Application Timestamp" value="40ce670d"/>
        <PARAMETER id="3" name="Fault Module Name" value="GPFMe.exe"/>
        <PARAMETER id="4" name="Fault Module Version" value="6.0.4082.0"/>
        <PARAMETER id="5" name="Fault Module Timestamp" value="40ce670d"/>
        <PARAMETER id="6" name="Exception Code" value="c0000005"/>
        <PARAMETER id="7" name="Exception Offset" value="000031de"/>
        </SIGNATURE>
        <FILES>
        <FILE filetype="5" filename="Version.txt"/>
        </FILES>
        </WERREPORT>
        """
    report = wer.Report.from_string(xml_string)
    assert isinstance(report, wer.Report)<commit_msg>Add test for XML loading from file<commit_after>from __future__ import unicode_literals

import wer


def test_main():
    assert wer


def test_loading_from_string():
    xml_string = b"""<?xml version="1.0" encoding="UTF-8"?>
        <WERREPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <MACHINEINFO machinename="client-machine.corp.cliendomain.com" os="6.1.6561.2.0.0.256.1"
        lcid="1033"/>
        <USERINFO username="Username"/>
        <APPLICATIONINFO appname="WER GPF Test Utility" apppath="E:\tools\GPFMe.exe" appcompany="Test
        Corporation"/>
        <EVENTINFO reporttype="2" eventtime="128496925196486378" eventtype="APPCRASH"
        friendlyeventname="Stopped working"/>
        <SIGNATURE>
        <PARAMETER id="0" name="Application Name" value="GPFMe.exe"/>
        <PARAMETER id="1" name="Application Version" value="6.0.4082.0"/>
        <PARAMETER id="2" name="Application Timestamp" value="40ce670d"/>
        <PARAMETER id="3" name="Fault Module Name" value="GPFMe.exe"/>
        <PARAMETER id="4" name="Fault Module Version" value="6.0.4082.0"/>
        <PARAMETER id="5" name="Fault Module Timestamp" value="40ce670d"/>
        <PARAMETER id="6" name="Exception Code" value="c0000005"/>
        <PARAMETER id="7" name="Exception Offset" value="000031de"/>
        </SIGNATURE>
        <FILES>
        <FILE filetype="5" filename="Version.txt"/>
        </FILES>
        </WERREPORT>
        """
    report = wer.Report.from_string(xml_string)
    assert isinstance(report, wer.Report)


def test_loading_from_files():
    from os import path
    from glob import glob
    examples_path = path.join(path.basename(__file__), 'data', 'examples')
    for f in glob(path.join(examples_path, '*.wer')):
        report = wer.Report.from_file(f)
        assert isinstance(report, wer.Report)
{'fraction_non_alphanumeric': 0.1523809523809524, 'fraction_numerical': 0.05357142857142857, 'mean_word_length': 3.3200514138817483, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 2, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 2, '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': '720300', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1095, 'n_words': 217}