<commit_before>import pytest
import re
from selenium import webdriver
from selenium.common.exceptions import TimeoutException

from selene import config
from selene.common.none_object import NoneObject
from selene.conditions import exact_text
from selene.tools import s, get_driver, set_driver, ss
from tests.integration.helpers.givenpage import GivenPage

GIVEN_PAGE = NoneObject('GivenPage')  # type: GivenPage
original_timeout = config.timeout


def setup_module(m):
    driver = webdriver.Firefox()
    set_driver(driver)
    global GIVEN_PAGE
    GIVEN_PAGE = GivenPage(driver)


def teardown_module(m):
    config.timeout = original_timeout
    get_driver().quit()


def exception_message(ex):
    return [line.strip() if not re.match('\s*screenshot: /.*?/\.selene/screenshots/\d+?/screen_\d+\.png\s*',line)
            else 'screenshot: //.selene/screenshots/*/screen_*.png'
            for line in str(ex.value.msg).strip().splitlines()]


def test_selement_search_fails_with_message_when_explicitly_waits_for_condition():
    GIVEN_PAGE.opened_with_body('''
    <label id='element'>Hello world!</label>
    ''')
    config.timeout = 0.1

    with pytest.raises(TimeoutException) as ex:
        s('#element').should_have(exact_text('Hello wor'))

    assert exception_message(ex) == \
           ['failed while waiting 0.1 seconds',
            'to assert exact_text(Hello wor)',
            "for element located by: first_by('css selector', '#element'),",
            'expected: Hello wor',
            'actual: Hello world!',
            '',
            'reason: ConditionMismatchException: condition did not match',
            'screenshot: //.selene/screenshots/*/screen_*.png']


def test_selement_search_fails_with_message_when_implicitly_waits_for_condition():
    GIVEN_PAGE.opened_with_body('''
    <button id='hidden-button' style='display:none'>You can't click me, ha ha! :P</button>
    ''')
    config.timeout = 0.1

    with pytest.raises(TimeoutException) as ex:<commit_msg>fix error msg tests for windows<commit_after>import pytest
import re
from selenium import webdriver
from selenium.common.exceptions import TimeoutException

from selene import config
from selene.common.none_object import NoneObject
from selene.conditions import exact_text
from selene.tools import s, get_driver, set_driver, ss
from tests.integration.helpers.givenpage import GivenPage

GIVEN_PAGE = NoneObject('GivenPage')  # type: GivenPage
original_timeout = config.timeout


def setup_module(m):
    driver = webdriver.Firefox()
    set_driver(driver)
    global GIVEN_PAGE
    GIVEN_PAGE = GivenPage(driver)


def teardown_module(m):
    config.timeout = original_timeout
    get_driver().quit()


def exception_message(ex):
    return [line.strip() if not re.match('\s*screenshot: .*?/\.selene/screenshots/\d+?/screen_\d+\.png\s*',line)
            else 'screenshot: //.selene/screenshots/*/screen_*.png'
            for line in str(ex.value.msg).strip().splitlines()]


def test_selement_search_fails_with_message_when_explicitly_waits_for_condition():
    GIVEN_PAGE.opened_with_body('''
    <label id='element'>Hello world!</label>
    ''')
    config.timeout = 0.1

    with pytest.raises(TimeoutException) as ex:
        s('#element').should_have(exact_text('Hello wor'))

    assert exception_message(ex) == \
           ['failed while waiting 0.1 seconds',
            'to assert exact_text(Hello wor)',
            "for element located by: first_by('css selector', '#element'),",
            'expected: Hello wor',
            'actual: Hello world!',
            '',
            'reason: ConditionMismatchException: condition did not match',
            'screenshot: //.selene/screenshots/*/screen_*.png']


def test_selement_search_fails_with_message_when_implicitly_waits_for_condition():
    GIVEN_PAGE.opened_with_body('''
    <button id='hidden-button' style='display:none'>You can't click me, ha ha! :P</button>
    ''')
    config.timeout = 0.1

    with pytest.raises(TimeoutException) as ex:
{'fraction_non_alphanumeric': 0.11842433308401895, 'fraction_numerical': 0.0029917726252804786, 'mean_word_length': 3.725559481743227, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6189175', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1245, 'n_words': 272}