Default skip test unless command line parameter present in py.test

前端 未结 2 1658
不思量自难忘°
不思量自难忘° 2021-02-19 01:38

I have a long run test, which lasts 2 days, which I don\'t want to include in a usual test run. I also don\'t want to type command line parameters, that would deselect it and ot

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 02:21

    try to decorate your test as @pytest.mark.longrun

    in your conftest.py

    def pytest_addoption(parser):
        parser.addoption('--longrun', action='store_true', dest="longrun",
                     default=False, help="enable longrundecorated tests")
    
    def pytest_configure(config):
        if not config.option.longrun:
            setattr(config.option, 'markexpr', 'not longrun')
    

提交回复
热议问题