Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from fixture.application import Application
  2. import pytest
  3.  
  4.  
  5. fixture = None
  6.  
  7.  
  8. @pytest.fixture()
  9. def app():
  10. global fixture
  11. if fixture is None:
  12. fixture = Application()
  13. else:
  14. if not fixture.is_valid():
  15. fixture = Application()
  16. fixture.session.ensure_login(username="admin", password="secret")
  17. return fixture
  18.  
  19.  
  20. @pytest.fixture(scope="session", autouse=True)
  21. def stop(request):
  22. def fin():
  23. fixture.session.ensure_logout()
  24. fixture.destroy()
  25. yield fixture
  26. request.addfinalizer(fin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement