diff --git a/bobtail/wsgi.py b/bobtail/wsgi.py index a15e2e6..7e52e25 100644 --- a/bobtail/wsgi.py +++ b/bobtail/wsgi.py @@ -62,6 +62,11 @@ def __init__(self, *args, **kwargs): _options = kwargs.get("options") if _options: self.options = _options + else: + class DefaultOptions(BaseOptions): + pass + + self.options = DefaultOptions() self.middleware = Middleware() def _handle_404(self, req: Request, res: Response): diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index 6de6ac2..cca6537 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -1,3 +1,5 @@ +import pytest + from tests.fixtures import bobtail_app from tests.fixtures import ( route_class_one, @@ -154,3 +156,15 @@ def test_args_not_in_path(self, bobtail_app, route_class_two, environ): data = self.app(env, lambda s, r: None) assert data is not None + def test_no_options(self, environ): + self.app = BobTail(routes=[]) + env = environ() + try: + _ = self.app(env, lambda s, r: None) + except AttributeError: + pytest.fail("Default options are not set!") + + assert self.app.options.PORT == 8000 + assert self.app.options.STATIC_DIR is "static" + assert self.app.options.TEMPLATE_DIR is "templates" +