-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from NatLibFi/annifexception-abstract-base-class
Turn AnnifException into an abstract base class and fix message prefix behavior
- Loading branch information
Showing
2 changed files
with
36 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Unit tests for Annif exception classes""" | ||
|
||
import pytest | ||
from annif.exception import AnnifException | ||
from click import ClickException | ||
|
||
|
||
def test_annifexception_not_instantiable(): | ||
with pytest.raises(TypeError): | ||
exc = AnnifException("test message") | ||
|
||
|
||
def test_annifexception_is_clickexception(): | ||
|
||
# we need to define a custom class to make an instantiable exception | ||
class CustomException(AnnifException): | ||
@property | ||
def prefix(self): | ||
return "my prefix" | ||
|
||
exc = CustomException("test message") | ||
assert isinstance(exc, ClickException) |