У меня проблемы с запуском unittest в моем классе. Сотрудник может мне помочь?
это test_employee.py:
import unittest
from employee import Employ
class TestEmployee(unittest.TestCase):
""" Test for the class Employee"""
def setUP(self):
"""Create an employee and the amount of salary that is given."""
first_name = 'Henry'
last_name = 'Chou'
annual_salary = 0
self.employee1 = Employ(first_name, last_name, annual_salary)
def test_give_default_raise(self):
self.employee1.giveRaise()
self.assertEqual(self.annual_salary, 5000)
def test_give_custom_raise(self):
self.employee1.giveRaise(8000)
self.assertEqual(self.annual_salary, 8000)
if __name__ == '__main__':
unittest.main()
Это модуль класса сотрудника: class Employ: "" "Определите класс Employee" ""
def __init__(self, first_name, last_name, annual_salary):
self.first_name = first_name
self.last_name = last_name
self.annual_salary = annual_salary
def giveRaise(self, amount = 5000):
self.annual_salary = self.annual_salary + amount
Когда я запускаю тест unnit, он показывает мне, что класс Employee не имеет атрибута объекта self.employee1.? почему это