homework11
2018-04-09 18:32
148 查看
11-1
city_functions.py
def city_country(city,country): return city+', '+country
test_cities.py
import unittest from city_functions import city_country class city_Test_class(unittest.TestCase): def test_city_country(self): String = city_country('Beijing', 'China') self.assertEqual(String,'Beijing, China') unittest.main()
11-2
1
city_functions.py
def city_country(city,country,population): return city+', '+country+' -population '+population
test_cities.py
import unittest from city_functions import city_country class city_Test_class(unittest.TestCase): def test_city_country(self): String = city_country('Beijing', 'China') self.assertEqual(String,'Beijing, China') unittest.main()
2
city_functions.py
def city_country(city,country,population=''): if population == '': return city+', '+country else: return city+', '+country+' -population '+population
test_cities.py
import unittest from city_functions import city_country class city_Test_class(unittest.TestCase): def test_city_country(self): String = city_country('Beijing', 'China') self.assertEqual(String,'Beijing, China') unittest.main()
3
city_functions.py
def city_country(city,country,population=''): if population == '': return city+', '+country else: return city+', '+country+' -population '+population
test_cities.py
import unittest from city_functions import city_country class city_Test_class(unittest.TestCase): def test_city_country(self): String = city_country('Beijing', 'China') self.assertEqual(String,'Beijing, China') def test_city_country_population(self): String = city_country('Beijing','China','10000') self.assertEqual(String,'Beijing, China -population 10000') unittest.main()
11-3
employee.py
class Employee(): def __init__(self, name, surname, money): self.property={'name':name,'surname':surname,'money':money} def give_raise(self,num = 5000): self.property['money'] += num
test_employee.py
from employee import Employee import unittest class Money_test_class(unittest.TestCase): def setUp(self): self.employee = Employee('jack','q',3000) def test_give_default_raise(self): self.employee.give_raise() self.assertEqual(8000, self.employee.property['money']) def test_give_custom_raise(self): self.employee.give_raise(2000) self.assertEqual(5000, self.employee.property['money']) unittest.main()
相关文章推荐
- C-11-26-homework
- 深入理解计算机系统_3e 第十一章家庭作业 CS:APP3e chapter 11 homework
- homework-07 C++ 11 能好怎
- 【homework11】测试自动化
- C++ 11 复习要点
- 一步步学习微软InfoPath2010和SP2010--第十三章节--SharePoint视图和仪表板(11)--KPI Web部件
- jsp小结11 - 9个内置对象04 out
- Java工具集介绍11_16
- Vaadin Web应用开发教程(11):UI组件-TextArea
- C++ 11 可变模板参数的两种展开方式
- 转connect() to unix:/var/run/php-fpm.sock failed (11: Resource temporarily unavailable)
- C++ Primer 学习笔记_11_指针
- 水晶報表模組更新11/30
- HDOJ---1074 Doing Homework[DP+状态压缩]
- 数据库操作练习11
- C++编程练习(11)----“图的最短路径问题“(Dijkstra算法、Floyd算法)
- FPGA研发之道(11)-设计不是凑波形(一)FIFO(上)
- Windows2000 DNS 技术指南 11
- Java多线程编程--(11)学习Java5.0 并发编程包--支持并发的集合类
- LeetCode-11-Container-With-Most-Water 贪心