fix: add AppHandler.load_object()
method
This commit is contained in:
parent
ae973881af
commit
ef5b13a297
|
@ -165,6 +165,21 @@ class AppHandler:
|
|||
self.model = importlib.import_module(spec)
|
||||
return self.model
|
||||
|
||||
def load_object(self, spec):
|
||||
"""
|
||||
Import and/or load and return the object designated by the
|
||||
given spec string.
|
||||
|
||||
This invokes :func:`wuttjamaican.util.load_object()`.
|
||||
|
||||
:param spec: String of the form ``module.dotted.path:objname``.
|
||||
|
||||
:returns: The object referred to by ``spec``. If the module
|
||||
could not be imported, or did not contain an object of the
|
||||
given name, then an error will raise.
|
||||
"""
|
||||
return load_object(spec)
|
||||
|
||||
def make_appdir(self, path, subfolders=None, **kwargs):
|
||||
"""
|
||||
Establish an :term:`app dir` at the given path.
|
||||
|
|
|
@ -11,6 +11,7 @@ import pytest
|
|||
|
||||
from wuttjamaican import app
|
||||
from wuttjamaican.conf import WuttaConfig
|
||||
from wuttjamaican.util import UNSPECIFIED
|
||||
|
||||
|
||||
class TestAppHandler(TestCase):
|
||||
|
@ -25,6 +26,13 @@ class TestAppHandler(TestCase):
|
|||
self.assertEqual(self.app.handlers, {})
|
||||
self.assertEqual(self.app.appname, 'wuttatest')
|
||||
|
||||
def test_load_object(self):
|
||||
|
||||
# just confirm the method works on a basic level; the
|
||||
# underlying function is tested elsewhere
|
||||
obj = self.app.load_object('wuttjamaican.util:UNSPECIFIED')
|
||||
self.assertIs(obj, UNSPECIFIED)
|
||||
|
||||
def test_make_appdir(self):
|
||||
|
||||
# appdir is created, and 3 subfolders added by default
|
||||
|
|
Loading…
Reference in a new issue