Exemplo n.º 1
0
    def test_list_for_correct_index_of_none(self):
        test_class = ClassList(3)
        test_class.add_student('Larry')
        test_class.add_student('Curly')
        test_class.add_student('Moe')

        self.assertEqual(None, test_class.index_of_student('Harry'))
        self.assertEqual(None, test_class.index_of_student('Hermione'))
        self.assertEqual(None, test_class.index_of_student('Ron'))

        self.assertIsNone(test_class.index_of_student('Mike'))
Exemplo n.º 2
0
    def test_index_of_student_student_present(self):
        test_class = ClassList(3)
        test_class.add_student('Harry')
        test_class.add_student('Hermione')
        test_class.add_student('Ron')

        self.assertEqual(1, test_class.index_of_student('Harry'))
        self.assertEqual(2, test_class.index_of_student('Hermione'))
        self.assertEqual(3, test_class.index_of_student('Ron'))

        # This assert passes, but it's redundant - the first assert statement will fail if
        # the method call returns None
        self.assertIsNotNone(test_class.index_of_student('Harry'))
Exemplo n.º 3
0
 def test_index_of_student_returns_none_on_empty_list(self):
     test_class = ClassList(3)
     self.assertIsNone(test_class.index_of_student('Mike'))
Exemplo n.º 4
0
 def test_index_of_student_when_list_is_not_empty(self):
     test_class = ClassList(2)
     test_class.add_student('Student Number1')
     test_class.add_student('Student Number2')
     self.assertIsNone(test_class.index_of_student('Student Number3'))
Exemplo n.º 5
0
 def test_index_of_student_is_none_if_classlist_is_empty(self):
     test_class = ClassList(2)
     index = test_class.index_of_student('Test Student')
     self.assertIsNone(index)