当前位置:网站首页>Pytest assert encapsulation

Pytest assert encapsulation

2022-06-25 21:19:00 Strange meow

because pytest Self contained assert When the assertion fails , The actual and expected results of the failure will not be printed , Bring invariance to the view , So it is necessary to package, format and print

import logging

import pytest

from common.baselogger import logger


def assert_equal(actual, expected):
    assert actual == expected, " The actual result is :{0},  The expected result is :{1}".format(actual, expected)


def assert_not_equal(a, b):
    assert a != b, "{0} be equal to {1}".format(a, b)


def assert_in(a, b):
    assert a in b, "{0} It doesn't contain {1}".format(b, a)


def assert_true(value):
    assert value, "{0}  For false ".format(value)

原网站

版权声明
本文为[Strange meow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202181330334805.html