Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101852
  • 博文数量: 45
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 368
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-21 16:28
文章分类

全部博文(45)

文章存档

2014年(45)

我的朋友

分类: WINDOWS

2014-05-05 09:53:44

下面是unittest模块的常用方法:

assertEqual(a, b)     a == b      

assertNotEqual(a, b)     a != b      

assertTrue(x)     bool(x) is True      

assertFalse(x)     bool(x) is False      

assertIs(a, b)     a is b     2.7

assertIsNot(a, b)     a is not b     2.7

assertIsNone(x)     x is None     2.7

assertIsNotNone(x)     x is not None     2.7

assertIn(a, b)     a in b     2.7

assertNotIn(a, b)     a not in b     2.7

assertIsInstance(a, b)     isinstance(a, b)     2.7

assertNotIsInstance(a, b)     not isinstance(a, b)     2.7

assertAlmostEqual(a, b)     round(a-b, 7) == 0      

assertNotAlmostEqual(a, b)     round(a-b, 7) != 0      

assertGreater(a, b)     a > b     2.7

assertGreaterEqual(a, b)     a >= b     2.7

assertLess(a, b)     a < b     2.7

assertLessEqual(a, b)     a <= b     2.7

assertRegexpMatches(s, re)     regex.search(s)     2.7

assertNotRegexpMatches(s, re)     not regex.search(s)     2.7

assertItemsEqual(a, b)     sorted(a) == sorted(b) and works with unhashable objs     2.7

assertDictContainsSubset(a, b)     all the key/value pairs in a exist in b     2.7

assertMultiLineEqual(a, b)     strings     2.7

assertSequenceEqual(a, b)     sequences     2.7

assertListEqual(a, b)     lists     2.7

assertTupleEqual(a, b)     tuples     2.7

assertSetEqual(a, b)     sets or frozensets     2.7

assertDictEqual(a, b)     dicts     2.7

assertMultiLineEqual(a, b)     strings     2.7

assertSequenceEqual(a, b)     sequences     2.7

assertListEqual(a, b)     lists     2.7

assertTupleEqual(a, b)     tuples     2.7

assertSetEqual(a, b)     sets or frozensets     2.7

assertDictEqual(a, b)     dicts     2.7

阅读(3187) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~