Skip to main content

unittest 用例执行过滤, 可选择用例执行环境或用例级别进行过滤

Project description

testfilter

unittest 用例执行过滤, 可选择用例级别或用例级别进行过滤

如何使用它?

>>> pip install testfilter
import unittest
from testfilter import runIf, Filter

# 设置执行环境 执行级别
Filter.env = 'test'  # test uat prod/production 不区分大小写
Filter.level = 'p2'  # smoke/p1 p2 p3 p4 不区分大小写


class Demo(unittest.TestCase, metaclass=Filter.Meta):
    @runIf.env.NOT_PROD  # 非正式环境下执行
    def test_001(self):
        self.assertEqual(1, 1)

    @runIf.env.TEST  # 仅在测试环境下执行
    def test_002(self):
        self.assertEqual(1, 1)

    @runIf.env.UAT
    @runIf.env.TEST
    @runIf.level_in.P3   # 测试环境和 UAT 环境下,且用例优先级在 P3 以上执行
    def test_003(self):
        self.assertEqual(1, 1)

    @runIf.level_in.SMOKE
    def test_004(self):
        self.assertEqual(1, 1)


if __name__ == '__main__':

    unittest.main()

image

用例环境

Tag 英文 中文
TEST Testing 测试
UAT User Acceptance Test 用户验收测试
PROD Production 正式/生产

用例级别

Level:

SMOKE/P1 P2 P3 P4

用例级别参考

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testfilter-0.0.5.tar.gz (3.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page