def test_index_of_student_for_absent_name_returning_none(self): test_class = ClassList(3) self.assertIsNone(test_class.index_of_student('Harry')) test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') self.assertIsNone(test_class.index_of_student('Malfoy'))
def test_if_list_is_empty(self): test_class = ClassList(3) self.assertIsNone(test_class.index_of_student('Harry')) test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') self.assertIsNone( test_class.index_of_student('The one who should not be named'))
def test_index_of_student_who_is_not_in_class_to_be_none(self): test_class = ClassList(2) test_class.add_student('Harry') test_class.add_student('Sally') self.assertEqual(1, test_class.index_of_student('Harry')) self.assertEqual(2, test_class.index_of_student('Sally')) self.assertIsNone(test_class.index_of_student('Berry'))
def test_index_of_student_student_not_present(self): test_class = ClassList(2) self.assertIsNone(test_class.index_of_student('Jeff')) test_class.add_student('student_1') test_class.add_student('student_2') self.assertEqual(1, test_class.index_of_student('student_1')) self.assertEqual(2, test_class.index_of_student('student_2')) self.assertIsNone(test_class.index_of_student('student_3'))
def test_populated_index_of_student_student_not_present(self): test_class = ClassList(5) 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')) self.assertEqual(None, test_class.index_of_student('Test Student'))
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')) self.assertIsNotNone(test_class.index_of_student('Harry'))
def test_index_of_student_student_not_present(self): test_class = ClassList(3) test_class.add_student('Ryu') test_class.add_student('Chun-Li') test_class.add_student('Ken') self.assertEqual(1, test_class.index_of_student('Ryu')) self.assertEqual(2, test_class.index_of_student('Chun-Li')) self.assertEqual(3, test_class.index_of_student('Ken')) # expecting a none value if student is not in the list self.assertIsNone(test_class.index_of_student('Dumbledore'))
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'))
def test_index_of_student_with_class_containing_students(self): test_class = ClassList(3) test_class.add_student('example 1') test_class.add_student('example 2') test_class.add_student('example 3') index = test_class.index_of_student('Test Student') self.assertIsNone(index)
def test_student_not_in_list(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') self.assertIsNone(test_class.index_of_student('Jimmy'))
def test_INDEX_OF_STUDENT_returns_correct_index_when_student_not_in_list( self): test_class = ClassList(2) student = "Kitty Cat" test_class.add_student(student) ghost = "Friendly Casper" self.assertIsNone(test_class.index_of_student(ghost))
def test_index_of_student_is_none_if_classlist_is_not_empty(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('rihanna') test_class.add_student('john') index = test_class.index_of_student('james') self.assertIsNone(index)
def test_index_of_student_is_none_if_classlist_is_empty(self): # Arrange test_class = ClassList(5) # Action index = test_class.index_of_student('Test Student') # Assert self.assertIsNone(index)
def test_index_of_students(self): test_class = ClassList(2) test_class.add_student('Mich') test_class.add_student('Micha') test_class.add_student('Michael') self.assertIsNone(test_class.index_of_student('Jake'))
def test_index_of_student_is_none_if_not_in_class(self): test_class = ClassList(3) test_class.add_student('Ed') test_class.add_student('Edd') test_class.add_student('Eddy') self.assertIsNone(test_class.index_of_student('kanker'))
def test_index_of_student_in_empty_list_returns_none_when_list_not_empty(self): test_class = ClassList(5) test_class.add_student('Tony Micelli') test_class.add_student('Angela Bower') test_class.add_student('Samantha Micelli') index_of_missing_student = test_class.index_of_student('Mona Robinson') self.assertIsNone(index_of_missing_student)
def test_index_of_student_is_none_for_student_not_in_list(self): # Arrange test_class = ClassList(4) # Action test_class.add_student('Harry') test_class.add_student('Hermione') test_class.add_student('Ron') index = test_class.index_of_student('Hagrid') # Assert self.assertIsNone(index)
def test_none_when_empty #tests to return none when list is empty test_class = ClassList(2) with self.assertRaise(StudentError): self.assertIsNone(test_class.index_of_student('Student1') def test_none_when_student_not_present #tests to return none when student is not present test_class = ClassList(2) test_class.add_student('Studnet 2') with self.assertRaise(StudentError): self.assertIsNone(test_class.index_of_student('Student1') def test_is_class_full #tests if class is full test_class = ClassList(2) with self.assertRaise(StudentError): self.assertTrue(test_class.is_class_full) def test_is_class_full #tests if class is not full test_class = ClassList(2) with self.assertRaise(StudentError): self.assertFalse(test_class.is_class_full)
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')) ## However, it would be useful to check that index_of_student returns None if a student isn't present. def test_none_when_empty #tests to return none when list is empty test_class = ClassList(2) with self.assertRaise(StudentError): self.assertIsNone(test_class.index_of_student('Student1') def test_none_when_student_not_present #tests to return none when student is not present test_class = ClassList(2) test_class.add_student('Studnet 2') with self.assertRaise(StudentError): self.assertIsNone(test_class.index_of_student('Student1') def test_is_class_full #tests if class is full test_class = ClassList(2) with self.assertRaise(StudentError): self.assertTrue(test_class.is_class_full) def test_is_class_full #tests if class is not full test_class = ClassList(2) with self.assertRaise(StudentError): self.assertFalse(test_class.is_class_full)
def test_none_when_empty(self): test_class = ClassList(2) with self.assertRaise(StudentError): self.assertIsNone(test_class.index_of_student('Student1') ## TODO write another test when the list is not empty but does not contain the student name, assert that the correct index is returned. def test_none_when_not_present(self): test_class = ClassList(2) test_class.add_student('Studnet 2') with self.assertRaise(StudentError): self.assertIsNone(test_class.index_of_student('Student1') ## TODO write a test for your new is_class_full method when the class is full. use assertTrue def test_is_class_full(self): test_class = ClassList(2) with self.assertRaise(StudentError): self.assertTrue(test_class.is_class_full) ## TODO write a test for your new is_class_full method for when is empty, and when it is not full. Use assertFalse def test_is_class_full(self): test_class = ClassList(2) with self.assertRaise(StudentError): self.assertFalse(test_class.is_class_full)
def test_returns_none_if_student_not_in_list_empty(self): test_class = ClassList(1) self.assertIsNone(test_class.index_of_student('Snoop Dog'))
def test_returns_none_if_student_not_in_class(self): test_class = ClassList(1) test_class.add_student('Snoop Dog') self.assertIsNone(test_class.index_of_student('Qaalib'))
def test_index_with_nonexistent_student(self): test_class = ClassList(3) test_class.add_student('Joe Biden') self.assertIsNone(test_class.index_of_student('Ace Aventura'))
def test_for_index_student_if_student_not_present(self): test_class = ClassList(3) self.assertEqual(None, test_class.index_of_student('Test Student')) self.assertIsNone(test_class.index_of_student('Test Student'))
def test_is_not_in_list(self): test_class = ClassList(3) test_class.add_student('Harry') test_class.add_student('Larry') test_class.add_student('Berry') self.assertIsNone(test_class.index_of_student('Mary'))
def test_empty_class_list(self): test_class = ClassList(0) self.assertIsNone(test_class.index_of_student('Ben'))
def test_student_not_in_index_of_student_empty_list(self): test_class = ClassList(2) self.assertIsNone(test_class.index_of_student('Taylor'))
def test_index_of_student_not_in_full_list(self): test_class = ClassList(2) test_class.add_student('Nate') test_class.add_student('Taylor') self.assertIsNone(test_class.index_of_student('Test'))
def test_index_of_students_returns_none_if_list_empty(self): test_list = ClassList(2) self.assertIsNone(test_list.index_of_student('Billy Bob'))
def test_index_of_students_returns_none_if_not_exist_and_list_not_empty( self): test_list = ClassList(2) test_list.add_student('Billy Bob') test_list.add_student('Captain Picard') self.assertIsNone(test_list.index_of_student('Fat Albert'))