<commit_before># -*- coding: utf-8 -*-

import pytest_wish


TEST_FACTORIAL_PY = '''
def test_factorial(wish):
    factorial = wish
    assert factorial(0) == 1
    assert factorial(1) == 1
    assert factorial(21) == 51090942171709440000
'''
TEST_FACTORIAL_TXT = '''
# test
math:fabs # comment
 math:factorial
math:dummy
dummy:dummy
'''


def test_import_coverage():
    """Fix the coverage by pytest-cov, that may trigger after pytest_wish is already imported."""
    from imp import reload  # Python 2 and 3 reload
    reload(pytest_wish)


def test_help_message(testdir):
    result = testdir.runpytest(
        '--help',
    )
    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        'wish:',
        '*--wish-modules*',
        '*--wish-fail*',
    ])


def test_skip_wish(testdir):
    """Make sure that pytest accepts our fixture."""

    # create a temporary pytest test module
    testdir.makepyfile(TEST_FACTORIAL_PY)

    # run pytest with the following cmd args
    result = testdir.runpytest(
        '-v',
    )

    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        '*test_factorial*wish*SKIPPED',
    ])

    # make sure that that we get a '0' exit code for the testsuite
    assert result.ret == 0


def test_wish_modules(testdir):
    """Make sure that pytest accepts our fixture."""

    # create a temporary pytest test module
    testdir.makepyfile(TEST_FACTORIAL_PY)

    # run pytest with the following cmd args
    result = testdir.runpytest(
        '--wish-modules=math',
        '-v',
    )

    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        '*test_factorial*math:fabs*xfail',
        '*test_factorial*math:factorial*XPASS',
    ])

    # make sure that that we get a '0' exit code for the testsuite
    assert result.ret == 0


def test_wish_modules_all(testdir):
    testdir.makepyfile(TEST_FACTORIAL_PY)
    result = testdir.runpytest(
        '--wish-modules=all',
        '--wish-includes=math',
        '-v',
    )
    result.stdout.fnmatch_lines([
        '*test_factorial*math:fabs*xfail',
        '*test_factorial*math:factorial*XPASS',
    ])
    assert result.ret == 0


def test_wish_fail(testdir):
    testdir.makepyfile(TEST_FACTORIAL_PY)<commit_msg>Fix the test_wish_modules_all to use pip, an actually imported module always present.<commit_after># -*- coding: utf-8 -*-

import pytest_wish


TEST_FACTORIAL_PY = '''
def test_factorial(wish):
    factorial = wish
    assert factorial(0) == 1
    assert factorial(1) == 1
    assert factorial(21) == 51090942171709440000
'''
TEST_FACTORIAL_TXT = '''
# test
math:fabs # comment
 math:factorial
math:dummy
dummy:dummy
'''


def test_import_coverage():
    """Fix the coverage by pytest-cov, that may trigger after pytest_wish is already imported."""
    from imp import reload  # Python 2 and 3 reload
    reload(pytest_wish)


def test_help_message(testdir):
    result = testdir.runpytest(
        '--help',
    )
    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        'wish:',
        '*--wish-modules*',
        '*--wish-fail*',
    ])


def test_skip_wish(testdir):
    """Make sure that pytest accepts our fixture."""

    # create a temporary pytest test module
    testdir.makepyfile(TEST_FACTORIAL_PY)

    # run pytest with the following cmd args
    result = testdir.runpytest(
        '-v',
    )

    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        '*test_factorial*wish*SKIPPED',
    ])

    # make sure that that we get a '0' exit code for the testsuite
    assert result.ret == 0


def test_wish_modules(testdir):
    """Make sure that pytest accepts our fixture."""

    # create a temporary pytest test module
    testdir.makepyfile(TEST_FACTORIAL_PY)

    # run pytest with the following cmd args
    result = testdir.runpytest(
        '--wish-modules=math',
        '-v',
    )

    # fnmatch_lines does an assertion internally
    result.stdout.fnmatch_lines([
        '*test_factorial*math:fabs*xfail',
        '*test_factorial*math:factorial*XPASS',
    ])

    # make sure that that we get a '0' exit code for the testsuite
    assert result.ret == 0


def test_wish_modules_all(testdir):
    testdir.makepyfile(TEST_FACTORIAL_PY)
    result = testdir.runpytest(
        '--wish-modules=all',
        '--wish-includes=pip.exceptions',
        '-v',
    )
    result.stdout.fnmatch_lines([
        '*test_factorial*pip.exceptions:*xfail',
    ])
    assert result.ret == 0


def test_wish_fail(testdir):
    testdir.makepyfile(TEST_FACTORIAL_PY)
{'fraction_non_alphanumeric': 0.11037005163511188, 'fraction_numerical': 0.014629948364888123, 'mean_word_length': 3.007758620689655, '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': '4861080', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1548, 'n_words': 373}