<commit_before>
pytest_plugins = 'pytester'


TEST_FAIL = """
def foo():
    return 'foo'
def test_foo():
    assert 'bar' == foo()
"""

def test_fail_always_reexecute_test(testdir):
    test = testdir.makepyfile(TEST_FAIL)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test)
    result.stdout.fnmatch_lines([
            '*test_foo FAILED',
            ])
    result2 = testdir.runpytest('-v', '--incremental',
                                '--watch-path=%s'%test.dirpath(), test)
    result2.stdout.fnmatch_lines([
            '*test_foo FAILED',
            ])


TEST_OK =  """
def foo():
    return 'foo'
def test_foo():
    assert 'foo' == foo()
"""

TEST_OK_2 =  """
def foo():
    return 'foo'
def test_foo():
    assert 'foo' == foo()
    assert True
"""


def test_ok_reexecute_only_if_changed(testdir):
    # first time
    test = testdir.makepyfile(TEST_OK)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test)
    result.stdout.fnmatch_lines([
            '*test_foo PASSED',
            ])

    # second time not executed because up-to-date
    result2 = testdir.runpytest('-v', '--incremental',
                                '--watch-path=%s'%test.dirpath(), test)
    result2.stdout.fnmatch_lines([
            '*up-to-date*',
            ])

    # change file, re-execute tests
    test2 = testdir.makepyfile(TEST_OK_2)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test2)
    result.stdout.fnmatch_lines([
            '*test_foo PASSED',
            ])<commit_msg>added tests for skip/xfail.<commit_after>
pytest_plugins = 'pytester'


TEST_FAIL = """
def foo():
    return 'foo'
def test_foo():
    assert 'bar' == foo()
"""

def test_fail_always_reexecute_test(testdir):
    test = testdir.makepyfile(TEST_FAIL)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test)
    result.stdout.fnmatch_lines([
            '*test_foo FAILED',
            ])
    result2 = testdir.runpytest('-v', '--incremental',
                                '--watch-path=%s'%test.dirpath(), test)
    result2.stdout.fnmatch_lines([
            '*test_foo FAILED',
            ])


TEST_OK =  """
def foo():
    return 'foo'
def test_foo():
    assert 'foo' == foo()
"""

TEST_OK_2 =  """
def foo():
    return 'foo'
def test_foo():
    assert 'foo' == foo()
    assert True
"""


def test_ok_reexecute_only_if_changed(testdir):
    # first time
    test = testdir.makepyfile(TEST_OK)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test)
    result.stdout.fnmatch_lines([
            '*test_foo PASSED',
            ])

    # second time not executed because up-to-date
    result2 = testdir.runpytest('-v', '--incremental',
                                '--watch-path=%s'%test.dirpath(), test)
    result2.stdout.fnmatch_lines([
            '*up-to-date*',
            ])

    # change file, re-execute tests
    test2 = testdir.makepyfile(TEST_OK_2)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test2)
    result.stdout.fnmatch_lines([
            '*test_foo PASSED',
            ])


TEST_SKIP =  """
import pytest

@pytest.mark.skipif("True")
def test_my_skip():
    assert False # not executed

@pytest.mark.xfail
def test_my_fail():
    assert False
"""


def test_skip_same_behaviour_as_passed(testdir):
    # first time
    test = testdir.makepyfile(TEST_SKIP)
    result = testdir.runpytest('-v', '--incremental',
                               '--watch-path=%s'%test.dirpath(), test)
    result.stdout.fnmatch_lines([
            '*test_my_skip SKIPPED',
            '*test_my_fail xfail',
            ])

    # second time not executed because up-to-date
    result2 = testdir.runpytest('-v', '--incremental',
                                '--watch-path=%s'%test.dirpath(), test)
    result2.stdout.fnmatch_lines([
            '*up-to-date*',
            ])
{'fraction_non_alphanumeric': 0.15644317641464575, 'fraction_numerical': 0.0042796005706134095, 'mean_word_length': 2.041937816341287, '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': '6854262', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1409, 'n_words': 239}