通过命令argumen的鼻子测试套件

2024-09-26 22:53:00 发布

您现在位置:Python中文网/ 问答频道 /正文

试图把一个命令参数传给我的西装脚本:

from test_cases.test_quick_search import QuickSearchTest

args = ['-s --tc=url:https://our_dev_environment.co']

def run_suite():
    all_tests = TestLoader().loadTestsFromTestCase(QuickSearchTest)
    suite = LazySuite(all_tests)
    run(args,suite=suite)

if __name__ == '__main__':
    run_suite()

但它似乎没有任何作用


Tags: runfromtest命令脚本search参数args
1条回答
网友
1楼 · 发布于 2024-09-26 22:53:00

QuickSearchTestaunittest.TestCase子类?loadTestsFromTestCase将只找到TestCase子类中的测试。您可以查看all_tests的内容,看看它是否真的从模块/类加载了任何内容。在

假设run()是nosetestsrun,那么使用suite会带来一个非常严重的警告:

suite: Suite or list of tests to run (default: None). Passing a suite or lists of tests will bypass all test discovery and loading. ALSO NOTE that if you pass a unittest.TestSuite instance as the suite, context fixtures at the class, module and package level will not be used, and many plugin hooks will not be called. If you want normal nose behavior, either pass a list of tests, or a fully-configured nose.suite.ContextSuite.

通过手工组装和运行自己的测试,你会损失很多nosetest实用程序(在模块和类级别设置/拆卸等等)。在

run接受suite的测试列表,因此您可以在调用它时尝试使用suite= all_tests。在

或者,this SO answer可能会有帮助。在

相关问题 更多 >

    热门问题