Exemple #1
0
def test_tfquestion_add2():
    """test add 2 answer
    """
    true_answer_1 = exam.TrueFalseAnswer(True)
    true_answer_2 = exam.TrueFalseAnswer(True)
    quest = exam.TrueFalseQuest()
    quest.add_answer(true_answer_1)

    with pytest.raises(ValueError):
        quest.add_answer(true_answer_2)
Exemple #2
0
def test_tfquestion_add1():
    """test add 2 answer
    """
    true_answer = exam.TrueFalseAnswer(True)
    false_answer = exam.TrueFalseAnswer(False)
    quest = exam.TrueFalseQuest()
    quest.answers = (true_answer, false_answer)

    assert quest.answers == (true_answer, false_answer)
    assert quest.correct_answer == true_answer
Exemple #3
0
def test_tfquestion_add3():
    """test add 3 answer ... maybe redundant
    """
    true_answer_1 = exam.TrueFalseAnswer(True)
    false_answer = exam.TrueFalseAnswer(False)
    true_answer_2 = exam.TrueFalseAnswer(True)
    quest = exam.TrueFalseQuest()
    quest.add_answer(true_answer_1)

    with pytest.raises(ValueError):
        quest.answers = (true_answer_1, false_answer, true_answer_2)
Exemple #4
0
def test_exam_tfquestion():
    tfquestion1 = exam.MultiChoiceQuest("mc quest1 text", "subject")
    tfquestion1.answers = (exam.TrueFalseAnswer(True),
                           exam.TrueFalseAnswer(False))
    tfquestion2 = exam.MultiChoiceQuest("mc quest2 text", "subject")
    tfquestion2.answers = (exam.TrueFalseAnswer(False),
                           exam.TrueFalseAnswer(True))

    ex = exam.Exam(tfquestion1, tfquestion2)

    assert ex.questions[0].answers[1].image == Path()
    assert ex.questions[0].correct_answer.boolean is True
    assert ex.questions[1].text == "mc quest2 text"
    assert ex.questions[1].correct_answer.text == "False"
Exemple #5
0
def test_truefalse_attribute():
    a = exam.TrueFalseAnswer(True)
    expected_attr_load_sequence = ("boolean", "image")
    expected_type_caster_sequence = (bool, Path)

    assert a.attr_load_sequence == expected_attr_load_sequence
    assert a.type_caster_sequence == expected_type_caster_sequence
Exemple #6
0
def test_exam_mixquestion():
    mcquestion = exam.MultiChoiceQuest("mc quest1 text", "subject")
    mcquestion.answers = (
        exam.MultiChoiceAnswer("Q1 A1"),
        exam.MultiChoiceAnswer("Q1 A2"),
        exam.MultiChoiceAnswer("Q1 A3"),
    )
    tfquestion = exam.MultiChoiceQuest("mc quest2 text", "subject")
    tfquestion.answers = (exam.TrueFalseAnswer(False),
                          exam.TrueFalseAnswer(True))

    ex = exam.Exam(mcquestion, tfquestion)

    assert ex.questions[0].answers[1].image == Path()
    assert ex.questions[0].correct_option == "A"
    assert ex.questions[1].text == "mc quest2 text"
    assert ex.questions[1].correct_answer.text == "False"
Exemple #7
0
def test_tfquestion_add0():
    """test add an answer
    """
    answer = exam.TrueFalseAnswer(True)
    quest = exam.TrueFalseQuest()
    quest.add_answer(answer)

    assert quest.answers == (answer, )
    assert quest.correct_answer == answer
Exemple #8
0
def test_truefalse_init4():
    a = exam.TrueFalseAnswer(0)

    assert a.boolean is False
    assert a.text == "False"
Exemple #9
0
def test_truefalse_init3():
    a = exam.TrueFalseAnswer(1)

    assert a.boolean is True
    assert a.text == "True"
Exemple #10
0
def test_truefalse_init2():
    a = exam.TrueFalseAnswer(True)
    a.boolean = False

    assert a.boolean is False
    assert a.text == "False"
Exemple #11
0
def test_truefalse_init1():
    a = exam.TrueFalseAnswer(True, Path())

    assert a.boolean is True
    assert a.text == "True"
    assert a.image == Path()