Ejemplo n.º 1
0
 def test_assert_group_passes(self):
     with Execution('def add(a, b): return a+b', run_tifa=False) as e:
         with assert_group('add') as g:
             assert_equal(e.student.call('add', 1, 3), 4)
             assert_equal(e.student.call('add', 1, 4), 5)
             assert_equal(e.student.call('add', 1, 3), 4)
     self.assertFeedback(e, SUCCESS_MESSAGE)
Ejemplo n.º 2
0
def q1_1():
    assertHasFunction(student, 'add_5', args=["num"] * 5, returns="str")
    with assert_group('add'):
        assertEqual(student.call('add_5', 1, 2, 3, 4, 5), "12345")
        assertEqual(student.call('add_5', 5, 4, 3, 2, 1), "54321")
        assertEqual(student.call('add_5', 0, 0, 0, 0, 0), "00000")
    set_success(message="#1.1) You completed the add_5 function",
                group=section(1))
Ejemplo n.º 3
0
    def test_assert_group_passes_but_earlier_fails(self):
        with Execution('def add(a, b): return a+b', run_tifa=False) as e:
            assert_equal(e.student.call('add', 4, 1), 7)
            with assert_group('add') as g:
                assert_equal(e.student.call('add', 1, 3), 4)
                assert_equal(e.student.call('add', 1, 4), 5)
                assert_equal(e.student.call('add', 1, 3), 4)
        self.assertFeedback(
            e, """Failed Instructor Test
Student code failed instructor test.
I ran the code:
    add(4, 1)
The value of the result was:
    5
But I expected the result to be equal to:
    7""")
Ejemplo n.º 4
0
    def test_assert_group_fails_all(self):
        with Execution('def add(a, b): return a+b', run_tifa=False) as e:
            with assert_group('add') as g:
                assert_equal(e.student.call('add', 1, 3), 3)
                assert_equal(e.student.call('add', 1, 4), 6)
                assert_equal(e.student.call('add', 1, 3), 3)
        self.assertFeedback(
            e, """Failed Instructor Test
Student code failed instructor tests.
You passed 0/3 tests.

I ran your function add on some new arguments.
 | Arguments | Returned | Expected
× |     1, 3 | 4 | 3
× |     1, 4 | 5 | 6
× |     1, 3 | 4 | 3""")
Ejemplo n.º 5
0
    def test_assert_group_fails_some_errors(self):
        with Execution('def add(a, b): return a+b', run_tifa=False) as e:
            with assert_group('add') as g:
                assert_equal(e.student.call('add', 1, 2), 3)
                assert_equal(e.student.call('add', 1, 4), 6)
                assert_equal(e.student.call('add', 1, "2"), 3)
        self.assertFeedback(
            e, """Failed Instructor Test
Student code failed instructor tests.
You passed 1/3 tests.

I ran your function add on some new arguments.
 | Arguments | Returned | Expected
  |     1, 2 | 3 | 3
× |     1, 4 | 5 | 6
× |     1, '2' | unsupported operand type(s) for +: 'int' and 'str' | 3""")