def app(request): global fixture if fixture is None: fixture = Application() fixture.open_site() fixture.session.login(Auth(username='******', password='******')) else: if not fixture.valid(): fixture = Application() fixture.open_site() fixture.session.login( Auth(username='******', password='******')) return fixture