old_contents: # -*- coding: utf-8 -*-
  __author__ = 'Администратор'
  
  import pytest
  from fixture.application import Application
  
  @pytest.fixture(scope="session")
  def app(request):
      fixture = Application()
      request.addfinalizer(fixture.destroy)
      return fixture
new_contents: # -*- coding: utf-8 -*-
  __author__ = 'Администратор'
  
  import pytest
  from fixture.application import Application
  
  fixture = None
  
  @pytest.fixture
  def app(request):
      global fixture
      if fixture is None:
          fixture = Application()
          fixture.session.login(username = "admin", password = "secret")
      else:
          if not fixture.is_valid():
              fixture = Application()
              fixture.session.login(username = "admin", password = "secret")
      return fixture
  
  @pytest.fixture(scope="session", autouse = True)
  def stop(request):
      def fin():
              fixture.session.logout()
              fixture.destroy()
      request.addfinalizer(fin)
      return fixture
subject: Create smart fixture