Skip to content

Commit

Permalink
added exception test
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Apr 28, 2018
1 parent f34fed0 commit 26ce790
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from masonite.app import App
from masonite.view import View
from masonite.exception_handler import ExceptionHandler
import pytest
from masonite.exceptions import MissingContainerBindingNotFound

class ApplicationMock:
DEBUG = True

class StorageMock:
STATICFILES = {}

container = App()
container.bind('Application', ApplicationMock)
container.bind('View', View(container).render)
container.bind('Storage', StorageMock)
container.bind('ExceptionHandler', ExceptionHandler(container))

def test_exception_renders_view():
with pytest.raises(MissingContainerBindingNotFound):
assert container.make('ExceptionHandler').load_exception(KeyError)


def test_exception_raises_exception():
container.make('Application').DEBUG = False
with pytest.raises(KeyError):
assert container.make('ExceptionHandler').load_exception(KeyError)

0 comments on commit 26ce790

Please sign in to comment.