예제 #1
0
def test_will_import_from_regular_when_builtins_fail():
    i = ImportRedirector('foobar6', 'foobar6_%s', builtins='foobar6.builtins')
    i.import_func = MagicMock(side_effect=sys_modules_side_effect)

    mod = i.load_module('foobar6.another')
    i.import_func.assert_called_once_with('foobar6.builtins.another')

    assert mod is sys.modules['foobar6.another']
    assert mod is sys.modules['foobar6.builtins.another']
    assert mod is i.module.another
예제 #2
0
def test_will_import_basic():
    i = ImportRedirector('foobar4', 'foobar4_%s')
    i.import_func = MagicMock(side_effect=sys_modules_side_effect)

    mod = i.load_module('foobar4.another')
    i.import_func.assert_called_with('foobar4_another')

    assert mod is sys.modules['foobar4.another']
    assert mod is sys.modules['foobar4_another']
    assert mod is i.module.another
예제 #3
0
def test_will_return_existing():
    i = ImportRedirector('foobar3', 'foobar3_%s')

    m = i.load_module('sys')
    assert m is sys
예제 #4
0
def test_will_ignore_properly():
    i = ImportRedirector('foobar2', 'foobar2_%s')

    assert i.find_module('asdf') is None
    assert i.find_module('another.two') is None
예제 #5
0
def test_has_module():
    i = ImportRedirector('foobar1', 'foobar1_%s')
    assert isinstance(i.module, types.ModuleType)
예제 #6
0
logging.getLogger(__name__).addHandler(NullHandler())

# Cleanup namespace
del NullHandler, logging

# Imports we import into the namespace.
from hoboken.application import HobokenBaseApplication, condition, halt, \
    pass_route

# Submodules we pull in here.
from . import matchers
from . import exceptions

# Grab mixins.
from hoboken.helpers import *


# Build our actual application.
class HobokenApplication(HobokenBaseApplication, HobokenCachingMixin,
                         HobokenRedirectMixin, HobokenRenderMixin):
    pass


# Create our extension module.
# This will first try and import a module from 'hoboken.builtin_ext.whatever',
# and, if that isn't found, from 'hoboken_whatever'.
from hoboken.exthook import ImportRedirector
ext = ImportRedirector('hoboken.ext',
                       'hoboken_%s',
                       builtins='hoboken.builtin_ext').module