The Python "teardown_class" is not behaving as I expect it to. Below is a summary of my code:
@classmethod
def setup_class(cls):
cls.create_table(table1)
cls.create_table(table2)
cls.create_table(table3)
@classmethod
def create_table(cls, some_arg_here):
"""Some code here that creates the table"""
def test_foo(self):
"""Some test code here"""
@classmethod
def teardown_class(cls):
"""Perform teardown things"""
I believe the way it is executing is that:
- create_table is being called from setup with 1st parameter (table1)
- Code in create_table executes
- Code in teardown_class executes
- 1-3 above is executed again with the 2nd parameter
- 1-3 above is executed again with the 3rd parameter
- Code in test_foo executes
How I expect it to perform:
- create_table is called with 1st parameter (table1)
- Code in create_table executes
- create_table is called with 2nd parameter (table 2)
- Code in create_table executes
- create_table is called with 3rd parameter (table 3)
- Code in create_table executes
- Code in test_foo executes
- Code in teardown_class executes
Python 2.7.10, pytest-3.6.2, py-1.5.3, pluggy-0.6.0