Skip to content

Commit

Permalink
Merge pull request #1101 from iElectric/nothandledclass
Browse files Browse the repository at this point in the history
Report correct class when raising NotHandled
  • Loading branch information
acdha committed Jan 14, 2015
2 parents 3249597 + 6c9024c commit d5c5325
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion haystack/utils/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def get_index(self, model_klass):
self.build()

if model_klass not in self.indexes:
raise NotHandled('The model %s is not registered' % model_klass.__class__)
raise NotHandled('The model %s is not registered' % model_klass)

return self.indexes[model_klass]

Expand Down
4 changes: 4 additions & 0 deletions test_haystack/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ def setUp(self):

def test_get_index(self):
self.assertRaises(NotHandled, self.ui.get_index, MockModel)
try:
self.ui.get_index(MockModel)
except NotHandled as e:
self.assertTrue(MockModel.__name__ in str(e))

self.ui.build(indexes=[BasicMockModelSearchIndex()])
self.assertTrue(isinstance(self.ui.get_index(MockModel), indexes.BasicSearchIndex))
Expand Down

0 comments on commit d5c5325

Please sign in to comment.