/hyde/tests/test_layout.py

http://github.com/hyde/hyde · Python · 40 lines · 27 code · 7 blank · 6 comment · 0 complexity · 6da0eeaef6f4d277f773b53a2d7843f9 MD5 · raw file

  1. # -*- coding: utf-8 -*-
  2. """
  3. Use nose
  4. `$ pip install nose`
  5. `$ nosetests`
  6. """
  7. import os
  8. from hyde.layout import Layout, HYDE_DATA, LAYOUTS
  9. from fswrap import File
  10. from nose.tools import nottest, with_setup
  11. DATA_ROOT = File(__file__).parent.child_folder('data')
  12. LAYOUT_ROOT = DATA_ROOT.child_folder(LAYOUTS)
  13. @nottest
  14. def setup_data():
  15. DATA_ROOT.make()
  16. @nottest
  17. def cleanup_data():
  18. DATA_ROOT.delete()
  19. def test_find_layout_from_package_dir():
  20. f = Layout.find_layout()
  21. assert f.name == 'basic'
  22. assert f.child_folder('layout').exists
  23. @with_setup(setup_data, cleanup_data)
  24. def test_find_layout_from_env_var():
  25. f = Layout.find_layout()
  26. LAYOUT_ROOT.make()
  27. f.copy_to(LAYOUT_ROOT)
  28. os.environ[HYDE_DATA] = unicode(DATA_ROOT)
  29. f = Layout.find_layout()
  30. assert f.parent == LAYOUT_ROOT
  31. assert f.name == 'basic'
  32. assert f.child_folder('layout').exists
  33. del os.environ[HYDE_DATA]