examples/pytest/fixtures.py
import pytest
import application


@pytest.fixture()
def getapp():
    print('getapp starts')
    app = application.App()
    
    yield app

    app.shutdown()
    print('getapp ends')

def test_add_user_foo(getapp):
    getapp.add_user("Foo")
    assert True

def test_add_user_bar(getapp):
    getapp.add_user("Bar")
    assert True

examples/pytest/application.py
class App(object):
    def __init__(self):
        self.pi = 3.14
        # .. set up database
        print("__init__ of App")


    def shutdown(self):
        print("shutdown of App cleaning up database")


    def add_user(self, name):
        print("Working on add_user({})".format(name))
$ pytest -s -q fixtures.py

getapp starts
__init__ of App
Working on add_user(Bar)
.shutdown of App cleaning up database
getapp ends

getapp starts
__init__ of App
Working on add_user(Foo)
.shutdown of App cleaning up database
getapp ends