示例#1
0
 def test_1(self):
     #Testing __str__
     s = Student("111", "Carter", "Marilyn", "312/333/2222", 1)
     self.assertEqual(str(s), "111, Carter, Marilyn, 312/333/2222, 1")
     #Testing __repr__
     s = Student(112, "Snow", "Jon", "312/2222/2222", 2)
     c = s.__repr__()
     self.assertEqual(c, {2, 112, '312/2222/2222', 'Snow', 'Jon'})
     #Testing instanced members
     s = Student(112, "Snow", "Jon", "312/2222/2222", 2)
     self.assertEqual(s.username, 112)
     self.assertEqual(s.last, "Snow")
     self.assertEqual(s.first, "Jon")
     self.assertEqual(s.phone, "312/2222/2222")
     self.assertEqual(s.yr, 2)
     #Update_year method
     s = Student(112, "Snow", "Jon", "312/2222/2222", 1)
     c = s.update_year()
     self.assertEqual(s.update_year(), 2)
     s = Student(112, "Snow", "Jon", "312/2222/2222", 2)
     c = s.update_year()
     self.assertEqual(s.update_year(), 3)
示例#2
0

from student import Student
#Traditional testing method

#Constructor method
s = Student(111, "Carter", "Marilyn", "312/333/2222", 1)
print(s)
#__repr__ method
s = Student(112, "Snow", "Jon", "312/2222/2222", 2)
#Testing instanced members
print(s.__repr__())
print(s.username)
print(s.first)
print(s.last)
print(s.phone)
print(s.yr)
#update_year for "s = Student(112, "Snow", "Jon", "312/2222/2222", 2)"
#updates by +1
print(s.update_year())