Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

Commit

Permalink
Fix tests and Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata committed Dec 31, 2016
1 parent 200befa commit 0a23d86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions kobin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ def _handle(self, environ):
response = _handle_unexpected_exception(e, self.config.get('DEBUG'))
return response

def wsgi(self, environ, start_response):
def __call__(self, environ, start_response):
"""It is called when receive http request."""
response = self._handle(environ)
start_response(response.status, response.headerlist)
return response.body

def __call__(self, environ, start_response):
"""It is called when receive http request."""
return self.wsgi(environ, start_response)


def _get_traceback_message(e):
message = '\n'.join(traceback.format_tb(e.__traceback__))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_handled_body_message_when_404_not_found(self):

def test_wsgi(self):
test_env = {'REQUEST_METHOD': 'GET', 'PATH_INFO': '/'}
actual = self.app.wsgi(test_env, self.dummy_start_response)
actual = self.app(test_env, self.dummy_start_response)
expected = [b'hello']
self.assertEqual(actual, expected)

Expand Down Expand Up @@ -129,7 +129,7 @@ def test_get_traceback_message(self):
actual = _get_traceback_message(e)
else:
actual = "Exception is not raised."
cause_of_exception = 'x = 1/0'
cause_of_exception = '1 / 0'
self.assertIn(cause_of_exception, actual)

def test_handle_unexpected_exception_should_return_500(self):
Expand Down

0 comments on commit 0a23d86

Please sign in to comment.