コード例 #1
0
def test_check_homework_function_returns_True():
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")
    hw = teacher.create_homework("Do it", 3)
    hw_result = student.do_homework(hw, "correct_solution")

    assert teacher.check_homework(hw_result) is True
コード例 #2
0
def test_do_homework_function_returns_HomeworkResult_object():
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")
    hw = teacher.create_homework("Do it", 3)
    result = student.do_homework(hw, "The solution of the student")

    assert isinstance(result, HomeworkResult)
コード例 #3
0
def test_do_homework_function_raises_Exception():
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")
    hw = teacher.create_homework("Do it", 0)
    with pytest.raises(DeadlineError) as info:
        student.do_homework(hw, "The solution of the student")

    assert "You are late." in str(info.value)
コード例 #4
0
def test_check_homework_function_adds_HomeworkResult_object_to_homework_done():
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")
    hw = teacher.create_homework("Do it", 3)
    hw_result = student.do_homework(hw, "correct_solution")
    teacher.check_homework(hw_result)

    assert isinstance(Teacher.homework_done[hw]["correct_solution"],
                      HomeworkResult)
コード例 #5
0
def test_reset_results_function_completely_frees_homework_done():
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")
    hw = teacher.create_homework("Do it", 3)
    hw2 = teacher.create_homework("Just do it", 5)
    hw_result = student.do_homework(hw, "correct_solution")
    hw_result2 = student.do_homework(hw2, "correct_solution2")
    teacher.check_homework(hw_result)
    teacher.check_homework(hw_result2)
    Teacher.reset_results()

    assert not Teacher.homework_done
コード例 #6
0
def test_reset_results_function_deletes_Homework_object_in_homework_done():
    Teacher.reset_results()
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")
    hw = teacher.create_homework("Do it", 3)
    hw_result = student.do_homework(hw, "correct_solution")
    teacher.check_homework(hw_result)
    Teacher.reset_results(hw)

    assert not Teacher.homework_done
コード例 #7
0
def test_class_Teacher_is_correctly_inherited_from_class_Student():
    student = Student("Valya", "Petrova")
    teacher = Teacher("Albert", "")

    assert student.first_name != teacher.first_name