楼主: fjac9713
2032 3

Python Testing Cookbook [推广有奖]

  • 3关注
  • 0粉丝

已卖:644份资源

博士生

26%

还不是VIP/贵宾

-

威望
0
论坛币
16983 个
通用积分
559.2651
学术水平
20 点
热心指数
11 点
信用等级
17 点
经验
19344 点
帖子
27
精华
3
在线时间
68 小时
注册时间
2014-7-11
最后登录
2024-12-2

楼主
fjac9713 发表于 2014-7-30 12:53:01 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币


  1. 书籍简介
  2. This cookbook is written as a collection of code recipes containing
  3. step-by-step directions on how to install or build different types of
  4. Python test tools to solve different problems. Each recipe contains
  5. explanations of how it works along with answers to common questions and
  6. cross references to other relevant recipes. The easy-to-understand
  7. recipe names make this a handy test reference book. Python developers
  8. and programmers with a basic understanding of Python and Python testing
  9. will find this cookbook beneficial. It will build on that basic
  10. knowledge equipping you with the intermediate and advanced skills
  11. required to fully utilize the Python testing tools. Broken up into lots
  12. of small code recipes, you can read this book at your own pace, whatever
  13. your experience. No prior experience of automated testing is required.
复制代码


本帖隐藏的内容

Python Testing Cookbook.pdf (9.14 MB, 需要: 5 个论坛币)




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Cookbook TESTING python Cook Book 电子书

本帖被以下文库推荐

沙发
songlinjl(真实交易用户) 发表于 2014-7-30 15:50:27 来自手机
  1. Getting nosy with testing

  2. Nose automatically discovers tests when fed with a package, a module, or a file.

  3. How to do it...
  4. With the following steps, we will explore how nose automatically finds test cases and runs them:

  5. Create a new file called recipe11.py in which to put all our code for this recipe.
  6. Create a class to test. For this recipe, we will use a shopping cart application that lets us load items and then calculate the bill.
  7. class ShoppingCart(object):
  8.     def __init__(self):
  9.         self.items = []

  10.     def add(self, item, price):
  11.         self.items.append(Item(item, price))
  12.         return self

  13.     def item(self, index):
  14.         return self.items[index-1].item

  15.     def price(self, index):
  16.         return self.items[index-1].price

  17.     def total(self, sales_tax):
  18.         sum_price = sum([item.price for item in self.items])
  19.         return sum_price*(1.0 + sales_tax/100.0)

  20.     def __len__(self):
  21.         return len(self.items)

  22. class Item(object):
  23.     def __init__(self, item, price):
  24.         self.item = item
  25.         self.price = price
  26. Create a test case that exercises the various parts of the shopping cart application.
  27. import unittest

  28. class ShoppingCartTest(unittest.TestCase):
  29.     def setUp(self):
  30.         self.cart = ShoppingCart().add("tuna sandwich", 15.00)

  31.     def test_length(self):
  32.         self.assertEquals(1, len(self.cart))

  33.     def test_item(self):
  34.         self.assertEquals("tuna sandwich", self.cart.item(1))

  35.     def test_price(self):
  36.         self.assertEquals(15.00, self.cart.price(1))

  37.     def test_total_with_sales_tax(self):
  38.         self.assertAlmostEquals(16.39, \
  39.                                 self.cart.total(9.25), 2)
  40. Use the command-line nosetests tool to run this recipe by filename and also by module.
复制代码

藤椅
Nicolle(真实交易用户) 学生认证  发表于 2015-8-31 03:17:48
提示: 作者被禁止或删除 内容自动屏蔽

板凳
Nicolle(真实交易用户) 学生认证  发表于 2015-8-31 03:19:06
提示: 作者被禁止或删除 内容自动屏蔽

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-30 04:09