PageRenderTime 24ms CodeModel.GetById 11ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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