Python 用于持续集成测试的库

Python library for continuous integration testing

我正在尝试制作一个用于持续集成的测试系统,我希望能够进行特定操作的检查,例如以特定方式格式化文件,并且这些检查需要有一个流程。

示例:

FormatFilesCheck(files):
    Test(see if formatter is installed)
    for prep in prework:
        Test(do prep)
        for file in files:
            Test(try formatting file)
    Test(clean up work)

我想知道是否有一个 python 库可以处理测试控制。显然有单元测试,但据我所知,这意味着线性测试,即使用依赖项进行测试。

如果 unittest 有这个能力,一个例子会很棒。

*编辑:我真正想要的是一个框架,它具有类似单元测试的错误处理和断言功能,它允许我编写检查并将它们插入其中。

提前致谢

如果我明白你在问什么,那么你正在寻找与 Chai JS 类似的东西。幸运的是,有人写了一个近似于它的python库,也叫Chai。你的测试用例看起来像这样:

FormatFilesCheck(files):
    expect(formatter.status).equals(installed)
    for prep in prework:
        do prep
        expect(prep).equals(what_prep_should_look_like)
        for file in files:
            format file
            expect(file).equals(what_file_should_look_like)
    clean up work
    # your expect/assert statements to make sure everything was cleaned up