I'm trying to move my unittest tests into pytest so I can easily parameterise them. The setUp function for one of the classes is:
def setUp(self):
self.engine.execute(f'DROP DATABASE IF EXISTS {db1}')
self.engine.execute(f'DROP DATABASE IF EXISTS {db2}')
What is the best way to replicate this in pytest? I realise there is setup_method() however I was cheating a little with unittest as not every method in that class needed that particular setup.
pytest recommend using fixtures but all the examples I see are returning objects, not executing functions. Can/should fixtures be used in this way?