How do I correctly setup and teardown for my pytest class with tests?

后端 未结 6 1022
名媛妹妹
名媛妹妹 2020-11-30 21:50

I am using selenium for end to end testing and I can\'t get how to use setup_class and teardown_class methods.

I need to set up browser in <

6条回答
  •  清歌不尽
    2020-11-30 22:17

    Your code should work just as you expect it to if you add @classmethod decorators.

    @classmethod 
    def setup_class(cls):
        "Runs once per class"
    
    @classmethod 
    def teardown_class(cls):
        "Runs at end of class"
    

    See http://pythontesting.net/framework/pytest/pytest-xunit-style-fixtures/

提交回复
热议问题