A flat-file CMS written in Python and Flask
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

test_settings.py 614B

123456789101112131415161718192021222324252627
  1. import json
  2. import os
  3. import shutil
  4. import tempfile
  5. import pytest
  6. from yird.settings import Settings
  7. def test_missing_yird_path():
  8. os.environ["YIRD_PATH"] = ""
  9. os.environ.pop("YIRD_PATH")
  10. with pytest.raises(KeyError):
  11. Settings()
  12. def test_reading_yird_path():
  13. root = tempfile.mkdtemp()
  14. os.environ["YIRD_PATH"] = root
  15. with open(os.path.join(root, "settings.json"), "w") as f:
  16. f.write(json.dumps({
  17. "PUBLIC_PATH": os.path.join(root, "public"),
  18. "SITE_NAME": "test website"
  19. }))
  20. assert Settings().YIRD_PATH == root
  21. shutil.rmtree(root)