def test_no_exec_or_eval_override(self, mock_get_input, mock_bonus):
        # GIVEN
        tasks = [
            [
                "",  # background info
                """What word is missing if you want spam to be written only twice?
                count = 1
                while count <= 5:
                    count = count + 1
                    print("spam")
                    if count == 3:
                    __________""",  # question
                ["break"],  # list of required keywords
                {"no_eval": True, "no_exec": True},  # dict of variables to set up before question
            ],
            [
                "",  # background info
                """What word is missing if you want to skip 'spam 3' ?
                count = 1
                while count <= 5:
                    count = count + 1
                    if count == 3:
                    __________
                print("spam " + str(count))""",  # question
                ["continue"],  # list of required keywords
                {"no_eval": True, "no_exec": True},  # dict of variables to set up before question
            ],
        ]

        # WHEN
        run(tasks, blurb="blah blah")

        # THEN
        assert mock_bonus.called_once_with()
    def test_run_shorter_tasks(self, mock_get_input, mock_bonus):

        # GIVEN
        tasks = [
            ["", "type a\n\n", ["a"], {"a": 1}],
            ["", 'type "b"\n\n', ["b"], {"b": 2}],
            ["", 'type "c"\n\n', ["c"], {"c": 3}],
        ]
        blurb = "This is a test run"
        run(tasks, blurb)

        # THEN
        assert mock_bonus.called_once_with()
        self.assertTrue(True)  # hacky, but set True to False to see what the output looks like
    def test_run(self, mock_bonus, mock_get_input):
        # GIVEN
        run(tasks, blurb)

        # THEN
        assert mock_bonus.called_once_with()
Beispiel #4
0
    equality_and_booleans,
    for_loops,
    functions,
    functions_quick_review,
    greater_than_less_than_and_booleans,
    inbuilt_functions_and_operators,
    indexing_lists,
    variables_equality_and_booleans,
    while_loops,
)
from unit_tests.test_instructor_code import *  # noqa

if input("\n\nPress enter to start\n") != "test":
    # LESSON ONE
    # https://kathrinschuler.github.io/slide-python-intro/#/10/3
    run(equality_and_booleans.TASKS, equality_and_booleans.BLURB)
    run(greater_than_less_than_and_booleans.TASKS, greater_than_less_than_and_booleans.BLURB)

    # https://kathrinschuler.github.io/slide-python-intro/#/11/4
    run(variables_equality_and_booleans.TASKS, variables_equality_and_booleans.BLURB)
    run(boolean_operators.TASKS, boolean_operators.BLURB)

    # LESSON TWO
    run(inbuilt_functions_and_operators.TASKS, inbuilt_functions_and_operators.BLURB)

    # LESSON THREE
    # https://kathrinschuler.github.io/slide-python-intro/#/25/4
    run(boolean_review.TASKS, boolean_review.BLURB)
    run(while_loops.TASKS, while_loops.BLURB)
    run(for_loops.TASKS, for_loops.BLURB)
    run(functions.TASKS, functions.BLURB)
Beispiel #5
0
"""
Press run above to start
"""

if input("\n\nPress enter to start\n") != "test":
    from exercises.question_runner import run

    # LESSON ONE
    # https://kathrinschuler.github.io/slide-python-intro/#/10/3
    from question_directory.equality_and_booleans import TASKS, BLURB
    from question_directory.greater_than_less_than_and_booleans import TASKS, BLURB

    # https://kathrinschuler.github.io/slide-python-intro/#/11/4
    from question_directory.variables_equality_and_booleans import TASKS, BLURB
    from question_directory.boolean_operators import TASKS, BLURB

    # LESSON TWO
    # No repl exercises for lesson 2

    # LESSON THREE
    # https://kathrinschuler.github.io/slide-python-intro/#/25/4
    from question_directory.functions import TASKS, BLURB

    run(TASKS, BLURB)

else:
    from unit_tests.test_instructor_code import *  # noqa

    if __name__ == "__main__":
        unittest.main()  # noqa
Beispiel #6
0
from exercises.question_runner import run
from question_directory import (
    boolean_operators,
    equality_and_booleans,
    functions,
    greater_than_less_than_and_booleans,
    inbuilt_functions_and_operators,
    lists,
    variables_equality_and_booleans,
)
from unit_tests.test_instructor_code import *  # noqa

if input("\n\nPress enter to start\n") != "test":
    # LESSON ONE
    # https://kathrinschuler.github.io/slide-python-intro/#/10/3
    run(equality_and_booleans.TASKS, equality_and_booleans.BLURB)
    run(greater_than_less_than_and_booleans.TASKS, greater_than_less_than_and_booleans.BLURB)

    # https://kathrinschuler.github.io/slide-python-intro/#/11/4
    run(variables_equality_and_booleans.TASKS, variables_equality_and_booleans.BLURB)
    run(boolean_operators.TASKS, boolean_operators.BLURB)

    # LESSON TWO
    run(inbuilt_functions_and_operators.TASKS, inbuilt_functions_and_operators.BLURB)

    # LESSON THREE
    # https://kathrinschuler.github.io/slide-python-intro/#/25/4
    run(functions.TASKS, functions.BLURB)

    # LESSON FOUR
    run(lists.TASKS, lists.BLURB)