Ejemplo n.º 1
0
 def test_top_students_org_dict_unmodified(self):
     """
     Test the original dictionaries are unmodified after
     top_students()
     """
     # this funciton is implemented after setUp
     # need to call top_students inside this function
     # to check if dict is unmodified after function call
     hw4.top_students(self.empty_class)
     self.assertEqual(self.empty_class, {})
     hw4.top_students(self.cs122)
     self.assertEqual(self.cs122, {
         'Zoe': 90,
         'Alex': 93,
         'Dan': 79,
         'Anna': 100
     })
Ejemplo n.º 2
0
 def test_top_students_2(self):
     """Test the top_students function with n = 2."""
     self.assertEqual(hw4.top_students(self.cs122, 2), ['Anna', 'Alex'])
     self.assertEqual(self.cs122, {
         'Zoe': 90,
         'Alex': 93,
         'Dan': 79,
         'Anna': 100
     })
Ejemplo n.º 3
0
 def test_top_students_empty(self):
     """
     Test top_student with empty dictionary and 6 argument
     """
     self.assertEqual(hw4.top_students(self.empty_class, 6), [])
Ejemplo n.º 4
0
 def test_top_students(self):
     """
     Test top_student with cs122 dictionary and no argument
     """
     self.assertEqual(hw4.top_students(self.cs122), ['Anna', 'Alex', 'Zoe'])
Ejemplo n.º 5
0
 def test_top_students_10(self):
     """
     Test top_student with cs122 dictionary and 10 argument
     """
     self.assertEqual(hw4.top_students(self.cs122, 10),
                      ['Anna', 'Alex', 'Zoe', 'Dan'])
Ejemplo n.º 6
0
 def test_top_students_empty(self):
     """Test the top_students function with empty dictionary."""
     self.assertEqual(hw4.top_students(self.empty_class, 6), [])
Ejemplo n.º 7
0
 def test_top_students_default(self):
     """Test the top_students function default parameter."""
     self.assertEqual(len(hw4.top_students(self.cs122)), 3)
Ejemplo n.º 8
0
 def test_top_students(self):
     """Continues to test several test cases for top_students()."""
     self.assertEqual(hw4.top_students(self.cs122, 2), ['Anna', 'Alex'])
     self.assertEqual(hw4.top_students(self.cs122, 10),
                      ['Anna', 'Alex', 'Zoe', 'Dan'])
     self.assertEqual(hw4.top_students(self.empty_class, 6), [])
Ejemplo n.º 9
0
 def test_top_students_default_args(self):
     """Test if top_students() works with default argument."""
     self.assertEqual(hw4.top_students(self.cs122), ['Anna', 'Alex', 'Zoe'])