Skip to content

Commit

Permalink
#72 AttributeError: 'BobTail' object has no attribute 'options'
Browse files Browse the repository at this point in the history
  • Loading branch information
joegasewicz committed Mar 6, 2024
1 parent 45bc846 commit 4891662
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 4891662

Please sign in to comment.