官术网_书友最值得收藏!

Powerful asserts

As you've probably already noticed, pytest makes use of the built-in assert statement to check assumptions during testing. Contrary to other frameworks, you don't need to remember various self.assert* or self.expect* functions. While this may not seem like a big deal at first, after spending some time using plain asserts, you will realize how much that makes writing tests more enjoyable and natural.

Again, here's an example of a failure:

________________________ test_default_health ________________________

def test_default_health():
health = get_default_health('warrior')
> assert health == 95
E assert 80 == 95

tests\test_assert_demo.py:25: AssertionError

Pytest shows the line of the failure, as well as the variables and expressions involved in the failure. By itself, this would be pretty cool already, but pytest goes a step further and provides specialized explanations of failures involving other data types.

主站蜘蛛池模板: 璧山县| 齐河县| 涿州市| 建平县| 龙里县| 汝南县| 阳谷县| 沂水县| 遂平县| 宾川县| 开封市| 延津县| 唐河县| 太康县| 平阴县| 喀什市| 遵义县| 罗源县| 定日县| 滨州市| 云安县| 承德县| 平安县| 江永县| 古丈县| 成都市| 保山市| 盐池县| 黔西| 兴化市| 修武县| 六安市| 牡丹江市| 钟山县| 白城市| 海宁市| 肇源县| 松溪县| 岳西县| 怀柔区| 左贡县|