Skip to content

Commit

Permalink
Merge pull request #10 from gregdenay/main
Browse files Browse the repository at this point in the history
InvalidNodeError now also ihnerits from KeyError
  • Loading branch information
gregdenay authored Jun 12, 2024
2 parents af79f46 + a757f85 commit 1f2b0c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 2.5.1

**Improvements**

* taxidTools.InvalidNodeError now ihnerits from KeyError as well, this might be more intuitive for some users

## 2.5.0

**New features**
Expand Down
2 changes: 1 addition & 1 deletion taxidTools/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.5.0"
__version__ = "2.5.1"
__title__ = "taxidTools"
__description__ = "A Python Toolkit for Taxonomy"
__author__ = "Gregoire Denay"
Expand Down
4 changes: 2 additions & 2 deletions taxidTools/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

class TaxonomyError(Exception):
"""Base Exception for all taxonomy related errors"""
default_message = 'An Taxonomy related error occured'
default_message = 'A Taxonomy related error occured'

def __init__(self, message:str = None):
super().__init__(message or self.default_message)


class InvalidNodeError(TaxonomyError):
class InvalidNodeError(TaxonomyError, KeyError):
"""Raised when a Node doesn't exist"""
2 changes: 2 additions & 0 deletions tests/test_Taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def test_copy(self):
self.assertIsNotNone(self.new.get('0', None))

def test_InvalidNodeError(self):
# Making sure InvalidNodeError can also be caught as a KeyError
self.assertRaises(taxidTools.InvalidNodeError, self.txd.__getitem__, "notataxid")
self.assertRaises(KeyError, self.txd.__getitem__, "notataxid")

def test_MergedNnode(self):
self.merged = taxidTools.MergedNode(10, 1)
Expand Down

0 comments on commit 1f2b0c7

Please sign in to comment.