1
0

conftest.py 608 B

123456789101112131415161718192021
  1. import pytest
  2. from utils import *
  3. # ref: https://stackoverflow.com/questions/22627659/run-code-before-and-after-each-test-in-py-test
  4. @pytest.fixture(autouse=True)
  5. def stop_server_after_each_test():
  6. # do nothing before each test
  7. yield
  8. # stop all servers after each test
  9. instances = set(
  10. server_instances
  11. ) # copy the set to prevent 'Set changed size during iteration'
  12. for server in instances:
  13. server.stop()
  14. @pytest.fixture(scope="module", autouse=True)
  15. def do_something():
  16. # this will be run once per test session, before any tests
  17. ServerPreset.load_all()