学生一枚求帮助 我真的觉得我没有错啊
class Employee():def __init__(self,first,last,salary):
self.first=first
self.last=last
self.salary=salary
def give_raise(self,increasement=''):
if increasement:
self.salary+=increasement
else:
self.salary+=5000
import unittest
class Employee(unittest.TestCase):
def setUp(self):
self.people=Employee('yang','zhenyu',0)
def test_give_default_raise(self):
self.people.give_raise()
self.assertEqual(self.people.salary,5000)
def test_give_custom_raise(self):
self.people.give_raise(10000)
self.assertEqual(self.people.salary,10000)
unittest.main()
EE
======================================================================
ERROR: test_give_custom_raise (__main__.Employee)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\86156\Desktop\测试.py", line 14, in setUp
self.people=Employee('yang','zhenyu',0)
TypeError: __init__() takes from 1 to 2 positional arguments but 4 were given
======================================================================
ERROR: test_give_default_raise (__main__.Employee)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\86156\Desktop\测试.py", line 14, in setUp
self.people=Employee('yang','zhenyu',0)
TypeError: __init__() takes from 1 to 2 positional arguments but 4 were given
----------------------------------------------------------------------
Ran 2 tests in 0.008s
FAILED (errors=2)
>>> 两个类都叫Employee? class Employee(unittest.TestCase):
def setUp(self):
self.people=Employee('yang','zhenyu',0)
Employee继承了unittest.TestCase,unittest.TestCase的__init__显示传入一个参数~虽然我不知道这模块是干啥的,但是self.people=Employee('yang','zhenyu',0)肯定不行~~
class TestCase(object):
def __init__(self, methodName='runTest'):
dlnb526 发表于 2020-2-6 16:06
Employee继承了unittest.TestCase,unittest.TestCase的__init__显示传入一个参数~虽然我不知道这模块是 ...
谢谢呀 冬雪雪冬 发表于 2020-2-6 16:02
两个类都叫Employee?
谢谢呀
页:
[1]