<commit_before>"""py.py unit tests."""
import pypyr.steps.py
import pytest


def test_py_single_code():
    """One word shell command works."""
    context = {'pycode': 'print(1+1)'}
    context = pypyr.steps.py.run_step(context)


def test_py_sequence():
    """Sequence of py code works and touches context."""
    context = {'pycode': "context['test'] = 1;"}
    pypyr.steps.py.run_step(context)

    context.update({'pycode': "context['test'] += 2"})
    pypyr.steps.py.run_step(context)

    context.update({'pycode': "context['test'] += 3"})
    pypyr.steps.py.run_step(context)

    assert context['test'] == 6, "context should be 6 at this point"


def test_py_sequence_with_semicolons():
    """Single py code string with semi - colons works."""
    context = {'pycode':
               'print(1); print(2); print(3);'}
    pypyr.steps.py.run_step(context)

    assert context == {'pycode':
                       'print(1); print(2); print(3);'}, ("""context in and out
                                                             the same""")


def test_py_sequence_with_linefeeds():
    """Single py code string with linefeeds works."""
    context = {'pycode':
               'print(1)\nprint(2)\nprint(3)'}
    pypyr.steps.py.run_step(context)


def test_pycode_error_throws():
    """pycode error should raise up to caller."""
    with pytest.raises(AssertionError):
        context = {'pycode': 'assert False'}
        pypyr.steps.py.run_step(context)


def test_no_pycode_context_throw():
    """No pycode in context should throw assert error."""
    with pytest.raises(AssertionError):
        context = {'blah': 'blah blah'}
        pypyr.steps.py.run_step(context)


def test_empty_pycode_context_throw():
    """Empty pycode in context should throw assert error."""
    with pytest.raises(AssertionError):<commit_msg>minor assert comment correction on py step test<commit_after>"""py.py unit tests."""
import pypyr.steps.py
import pytest


def test_py_single_code():
    """One word shell command works."""
    context = {'pycode': 'print(1+1)'}
    context = pypyr.steps.py.run_step(context)


def test_py_sequence():
    """Sequence of py code works and touches context."""
    context = {'pycode': "context['test'] = 1;"}
    pypyr.steps.py.run_step(context)

    context.update({'pycode': "context['test'] += 2"})
    pypyr.steps.py.run_step(context)

    context.update({'pycode': "context['test'] += 3"})
    pypyr.steps.py.run_step(context)

    assert context['test'] == 6, "context should be 6 at this point"


def test_py_sequence_with_semicolons():
    """Single py code string with semi - colons works."""
    context = {'pycode':
               'print(1); print(2); print(3);'}
    pypyr.steps.py.run_step(context)

    assert context == {'pycode':
                       'print(1); print(2); print(3);'}, ("context in and out "
                                                          "the same")


def test_py_sequence_with_linefeeds():
    """Single py code string with linefeeds works."""
    context = {'pycode':
               'print(1)\nprint(2)\nprint(3)'}
    pypyr.steps.py.run_step(context)


def test_pycode_error_throws():
    """pycode error should raise up to caller."""
    with pytest.raises(AssertionError):
        context = {'pycode': 'assert False'}
        pypyr.steps.py.run_step(context)


def test_no_pycode_context_throw():
    """No pycode in context should throw assert error."""
    with pytest.raises(AssertionError):
        context = {'blah': 'blah blah'}
        pypyr.steps.py.run_step(context)


def test_empty_pycode_context_throw():
    """Empty pycode in context should throw assert error."""
    with pytest.raises(AssertionError):
{'fraction_non_alphanumeric': 0.15010799136069114, 'fraction_numerical': 0.008639308855291577, 'mean_word_length': 3.0625, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5505457', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1159, 'n_words': 282}