def test_good_library_module_strict(self): ''' Test that :py:class:`runtime.Library` can properly load a known-good module, while enforcing ``strict`` mode. ''' with runtime.Library(operator, strict=True) as (library, _operator): assert hasattr(_operator, 'eq')
def test_bad_library_string_lax(self): ''' Test that :py:class:`runtime.Library` can properly ignore a known-bad module by its path, when not enforcing ``strict`` mode. ''' with runtime.Library('i_do_not_exist_at_all_okay_never', strict=False) as (library, wat): assert True is True
def test_good_library_string_lax(self): ''' Test that :py:class:`runtime.Library` can properly load a known-good module by its path, without enforcing ``strict`` mode. ''' with runtime.Library('operator', strict=False) as (library, operator): assert hasattr(operator, 'eq')
# -*- coding: utf-8 -*- ''' canteen HTTP cache-related logic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :author: Sam Gammon <*****@*****.**> :copyright: (c) Keen IO, 2013 :license: This software makes use of the MIT Open Source License. A copy of this license is included as ``LICENSE.md`` in the root of the project. ''' # core runtime from canteen.base import logic from canteen.core import runtime # canteen utils from canteen.util import decorators with runtime.Library('werkzeug', strict=True) as (library, werkzeug): @decorators.bind('caching') class Caching(logic.Logic): ''' ''' pass __all__ = ('Caching', )
''' # stdlib import json # canteen base & core from canteen.core import runtime from canteen.base import protocol ## Globals _content_types = ('application/json', 'application/x-javascript', 'text/javascript', 'text/x-javascript', 'text/x-json', 'text/json') with runtime.Library('protorpc') as (library, protorpc): # submodules protojson = library.load('protojson') @protocol.Protocol.register('jsonrpc', _content_types) class JSONRPC(protocol.Protocol, protojson.ProtoJson): ''' ''' class JSONMessageCodec(protojson.MessageJSONEncoder): ''' ''' pass def encode_message(self, message): ''' '''
''' # stdlib import json, time # core runtime from canteen.base import logic from canteen.core import runtime # canteen utils from canteen.util import decorators # core session API from canteen.core.api.session import SessionEngine with runtime.Library('werkzeug', strict=True) as (library, werkzeug): # subimports securecookie = library.load('contrib.securecookie') @decorators.bind('cookies') class Cookies(logic.Logic): ''' ''' __modes__ = {} # modes for dealing with cookies @classmethod def add_mode(cls, name): ''' ''' def _mode_adder(mode_klass): ''' '''