Is it possible to run tear down fixture only after all params runs?

前端 未结 1 1930
栀梦
栀梦 2021-01-22 17:43

For instance if you have:

@pytest.mark.parametrize(\'lang\',
                         [\"EN\",
                          \"FR\"])
def test_whats_hot_quick_links_         


        
相关标签:
1条回答
  • 2021-01-22 18:00

    For this behaviour I use scope=class and wraps my test with class:

    import pytest
    
    @pytest.yield_fixture(scope='class')
    def teardown_after_all_params():
        yield
        execute_at_the_end()
    
    @pytest.mark.usefixtures('teardown_after_all_params')
    class TestLinks:
        @pytest.mark.parametrize('lang', ["EN", "FR"])
        def test_whats_hot_quick_links_are_displayed(self, lang):
            # Do something here
    
    0 讨论(0)
提交回复
热议问题