mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
- tls config is no longer allowed in static config file, add separate dynamic config - no longer need to persist auth config ourselves (TraefikProxy handles this) - make sure to reload proxy before reloading hub in tests
30 lines
794 B
Python
30 lines
794 B
Python
"""pytest fixtures"""
|
|
|
|
import os
|
|
|
|
from pytest import fixture
|
|
|
|
|
|
@fixture
|
|
def preserve_config(request):
|
|
"""Fixture to save and restore config around tests"""
|
|
# Import TLJH only when needed. This lets us run tests in places
|
|
# where TLJH is not installed - particularly, the 'distro check' test.
|
|
from tljh.config import CONFIG_FILE, reload_component
|
|
|
|
if os.path.exists(CONFIG_FILE):
|
|
with open(CONFIG_FILE) as f:
|
|
save_config = f.read()
|
|
else:
|
|
save_config = None
|
|
try:
|
|
yield
|
|
finally:
|
|
if save_config:
|
|
with open(CONFIG_FILE, "w") as f:
|
|
f.write(save_config)
|
|
elif os.path.exists(CONFIG_FILE):
|
|
os.remove(CONFIG_FILE)
|
|
reload_component("proxy")
|
|
reload_component("hub")
|