當前位置: 首頁>>代碼示例>>Python>>正文


Python configuration.Configurable類代碼示例

本文整理匯總了Python中aspen.configuration.Configurable的典型用法代碼示例。如果您正苦於以下問題:Python Configurable類的具體用法?Python Configurable怎麽用?Python Configurable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Configurable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_nirvana

def test_nirvana():
    logging.getLogger().handlers = []  # override nose logging nosiness
    c = Configurable()
    c.configure(['-vNIRVANA'])
    actual = c.log_level
    expected = sys.maxint
    assert actual == expected, actual
開發者ID:buchuki,項目名稱:aspen,代碼行數:7,代碼來源:test_configuration.py

示例2: test_configurable_sees_root_option

def test_configurable_sees_root_option():
    mk()
    c = Configurable()
    c.configure(['--root', FSFIX])
    expected = os.getcwd()
    actual = c.root
    assert actual == expected, actual
開發者ID:buchuki,項目名稱:aspen,代碼行數:7,代碼來源:test_configuration.py

示例3: test_root_defaults_to_cwd

def test_root_defaults_to_cwd():
    mk()
    c = Configurable()
    c.configure([])
    expected = os.getcwd()
    actual = c.root
    assert actual == expected, actual
開發者ID:buchuki,項目名稱:aspen,代碼行數:7,代碼來源:test_configuration.py

示例4: test_www_root_defaults_to_cwd

def test_www_root_defaults_to_cwd():
    mk()
    c = Configurable()
    c.configure([])
    expected = os.path.realpath(os.getcwd())
    actual = c.www_root
    assert actual == expected, actual
開發者ID:ArmstrongJ,項目名稱:aspen-python,代碼行數:7,代碼來源:test_configuration.py

示例5: test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have__www_root

def test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have__www_root(harness):
    foo = os.getcwd()
    os.chdir(harness.fs.project.resolve(''))
    os.rmdir(os.getcwd())
    c = Configurable()
    c.configure(['--www_root', foo])
    assert c.www_root == foo
開發者ID:Acidburn0zzz,項目名稱:aspen-python,代碼行數:7,代碼來源:test_configuration.py

示例6: test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have___root

def test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have___root():
    mk()
    foo = os.getcwd()
    os.chdir(FSFIX)
    os.rmdir(os.getcwd())
    c = Configurable()
    c.configure(['--root', foo])
    expected = foo
    actual = c.root
    assert actual == expected, actual
開發者ID:buchuki,項目名稱:aspen,代碼行數:10,代碼來源:test_configuration.py

示例7: from_fs

 def from_fs(cls, fs):
     """Takes a path under ./fsfix using / as the path separator.
     """
     fs = os.sep.join(fs.split('/'))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     c = Configurable.from_argv(['fsfix'])
     c.copy_configuration_to(request)
     request.fs = fs
     request.namespace = {}
     request.website = Stub()
     request.website.template_loader = Stub()
     return request
開發者ID:falstaff84,項目名稱:aspen,代碼行數:12,代碼來源:__init__.py

示例8: from_fs

 def from_fs(cls, fs):
     """Takes a path under ./fsfix using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Configurable.from_argv(['--root', 'fsfix'])
     website.copy_configuration_to(request)
     request.root = join(dirname(__file__), 'fsfix')
     request.fs = fs
     request.namespace = {}
     request.website = website 
     request.website.template_loader = Stub()
     return request
開發者ID:jatr,項目名稱:aspen,代碼行數:13,代碼來源:__init__.py

示例9: test_defaults_to_defaults

def test_defaults_to_defaults(harness):
    c = Configurable()
    c.configure()
    actual = ( c.logging_threshold
             , c.project_root
             , c.www_root

             , c.changes_reload
             , c.charset_dynamic
             , c.charset_static
             , c.indices
             , c.list_directories
             , c.media_type_default
             , c.media_type_json
             , c.renderer_default
             , c.show_tracebacks
              )
    expected = ( 0, None, os.getcwd(), False, 'UTF-8', None
               , ['index.html', 'index.json', 'index', 'index.html.spt', 'index.json.spt', 'index.spt']
               , False, 'text/plain', 'application/json', 'stdlib_percent', False
                )
    assert actual == expected
開發者ID:jaraco,項目名稱:aspen,代碼行數:22,代碼來源:test_configuration.py

示例10: from_fs

 def from_fs(cls, fs, *a):
     """Takes a path under FSFIX using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Configurable.from_argv([ '--www_root', FSFIX
                                      , '--project_root', '.aspen'
                                       ] + list(a))
     request.www_root = os.path.join(os.path.dirname(__file__), FSFIX)
     request.fs = fs
     request.context = {}
     request.website = website 
     request._media_type = None
     return request
開發者ID:jarpineh,項目名稱:aspen,代碼行數:14,代碼來源:__init__.py

示例11: test_cheese_example

def test_cheese_example():
    mk(('configure-aspen.py', """\
from aspen.renderers import Renderer, Factory

class Cheese(Renderer):
    def render_content(self, context):
        return self.compiled.replace("cheese", "CHEESE!!!!!!")

class CheeseFactory(Factory):
    Renderer = Cheese

website.renderer_factories['excited-about-cheese'] = CheeseFactory(website)
"""))
    website = Configurable.from_argv(["--project_root", FSFIX])
    make_renderer = website.renderer_factories['excited-about-cheese']
    render = make_renderer("", "I like cheese!")  # test specline elsewhere
    actual = render({})
    assert actual == "I like CHEESE!!!!!!!", actual
開發者ID:allisonmobley,項目名稱:aspen,代碼行數:18,代碼來源:test_rendering.py

示例12: test_configurable_sees_root_option

def test_configurable_sees_root_option(harness):
    c = Configurable()
    c.configure(['--www_root', harness.fs.project.resolve('')])
    expected = harness.fs.project.root
    actual = c.www_root
    assert actual == expected
開發者ID:Acidburn0zzz,項目名稱:aspen-python,代碼行數:6,代碼來源:test_configuration.py

示例13: __init__

 def __init__(self, path):
     self.path = Path(path)
     c = Configurable.from_argv(['fsfix'])
     c.copy_configuration_to(self)
開發者ID:geekbuntu,項目名稱:aspen,代碼行數:4,代碼來源:test_gauntlet.py

示例14: test_that_a_renderer_factory_is_instantiable

def test_that_a_renderer_factory_is_instantiable():
    actual = TornadoFactory(Configurable.from_argv([])).__class__
    assert actual is TornadoFactory, actual
開發者ID:allisonmobley,項目名稱:aspen,代碼行數:3,代碼來源:test_rendering.py

示例15: tornado_factory_factory

def tornado_factory_factory(argv=None):
    if argv is None:
        argv = []
    return TornadoFactory(Configurable.from_argv(argv))
開發者ID:allisonmobley,項目名稱:aspen,代碼行數:4,代碼來源:test_rendering.py


注:本文中的aspen.configuration.Configurable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。