Skip to content

Commit

Permalink
Merge pull request #76 from joegasewicz/AttributeError_options-#72
Browse files Browse the repository at this point in the history
#72 AttributeError: 'BobTail' object has no attribute 'options'
  • Loading branch information
joegasewicz authored Mar 6, 2024
2 parents 45bc846 + 4891662 commit 114204c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bobtail/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_wsgi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from tests.fixtures import bobtail_app
from tests.fixtures import (
route_class_one,
Expand Down Expand Up @@ -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"

0 comments on commit 114204c

Please sign in to comment.