employ.py
待测试的类
class Employee():
def __init__(self,first_name,last_name,salary):
self.first_name=first_name
self.last_name=last_name
self.salary=salary
def give_raise(self,default=5000):
return int(self.salary)+default
test_employ.py
测试类
# coding=utf-8
import unittest
from employ import Employee
class TestEmploy(unittest.TestCase):
def setUp(self):
self.people=Employee("ZHU","Fangya",20000)
self.salary=[25000,30000]
def test_give_default_raise(self):
self.assertEqual(self.people.give_raise(),self.salary[0])
def test_give_custome_raise(self):
self.default=10000
self.assertEqual(self.people.give_raise(default=10000),self.salary[1])
if __name__=="__main__":
unittest.main()
Done:2 of 2 (0.137s) C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.0.6\helpers\pycharm\utrunner.py" C:\Users\waiwai\PycharmProjects\untitled2\test_employ.py true Testing started at 16:03 ... Process finished with exit code 0
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有