コード例 #1
0
def test_state_linking_root_creator_child_state(state, dummy_checks):
    def diagnose(end_state):
        assert end_state != state
        assert end_state.parent_state is state
        assert len(end_state.state_history) == 2
        assert state == end_state.state_history[0]
        assert end_state == end_state.state_history[1]

    TestEx = ExGen(state, dummy_checks)
    TestEx().child_state() >> F(attr_scts={"diagnose": diagnose}).diagnose()
コード例 #2
0
ファイル: test_check_files.py プロジェクト: shwivl/pythonwhat
def test_file_existence_syntax(temp_py_file):
    """test integration of protowhat checks in pythonwhat"""
    expected_content = cf.get_file_content(temp_py_file.name)
    chain = setup_state("", "", pec="")

    file_chain = chain.check_file(temp_py_file.name)
    assert expected_content in file_chain._state.student_code

    with helper.verify_sct(True):
        file_chain = chain >> F(attr_scts={
            "check_file": cf.check_file
        }).check_file(temp_py_file.name)
        assert expected_content in file_chain._state.student_code
コード例 #3
0
def test_debug(state, dummy_checks):
    state.do_test(Success("msg"))
    Ex = ExGen(state, dummy_checks)
    try:
        Ex().noop().child_state() >> F(attr_scts={"_debug": _debug})._debug(
            "breakpoint name"
        )
        assert False
    except TF as e:
        assert "breakpoint name" in str(e)
        assert "history" in str(e)
        assert "child_state" in str(e)
        assert "test" in str(e)
コード例 #4
0
def test_f_sct_copy_pos(addx):
    assert F()._sct_copy(addx)("x")("state") == "statex"
コード例 #5
0
def test_f_sct_copy_kw(addx):
    assert F()._sct_copy(addx)(x="x")("state") == "statex"
コード例 #6
0
def f2():
    return F._from_func(lambda state, c: state + c, c="c")
コード例 #7
0
def f():
    return F._from_func(lambda state, b: state + b, b="b")
コード例 #8
0
def test_state_linking_root_creator_noop(state, dummy_checks):
    def diagnose(end_state):
        assert end_state.creator is None

    TestEx = ExGen(state, dummy_checks)
    TestEx().noop() >> F(attr_scts={"diagnose": diagnose}).diagnose()
コード例 #9
0
def test_state_linking_root_creator(state):
    def diagnose(end_state):
        assert end_state.creator is None

    f = F(attr_scts={"diagnose": diagnose})
    Ex(state) >> f.diagnose()
コード例 #10
0
def test_f_sct_copy_pos(addx):
    assert F()._sct_copy(addx)('x')('state') == 'statex'
コード例 #11
0
def test_f_sct_copy_kw(addx):
    assert F()._sct_copy(addx)(x='x')('state') == 'statex'
コード例 #12
0
def test_check_file_fchain(state, temp_file):
    f = F(attr_scts={"check_file": cf.check_file})
    Ex(state) >> f.check_file(temp_file.name)