Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#72 AttributeError: 'BobTail' object has no attribute 'options' #76

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"

Loading