Skip to content

Commit

Permalink
Base class for all errors
Browse files Browse the repository at this point in the history
Closes #43
  • Loading branch information
Stuart Bishop committed Apr 28, 2020
1 parent fb8b146 commit 238b4f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pytz/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
]


class UnknownTimeZoneError(KeyError):
class Error(Exception):
'''Base class for all exceptions raised by the pytz library'''


class UnknownTimeZoneError(KeyError, Error):
'''Exception raised when pytz is passed an unknown timezone.
>>> isinstance(UnknownTimeZoneError(), LookupError)
Expand All @@ -20,11 +24,18 @@ class UnknownTimeZoneError(KeyError):
>>> isinstance(UnknownTimeZoneError(), KeyError)
True
And also a subclass of pytz.exceptions.Error, as are other pytz
exceptions.
>>> isinstance(UnknownTimeZoneError(), Error)
True
'''
pass


class InvalidTimeError(Exception):
class InvalidTimeError(Error):
'''Base class for invalid time exceptions.'''


Expand Down
1 change: 1 addition & 0 deletions src/pytz/tests/test_tzinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,7 @@ def test_suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite('pytz'))
suite.addTest(doctest.DocTestSuite('pytz.tzinfo'))
suite.addTest(doctest.DocTestSuite('pytz.exceptions'))
import test_tzinfo
suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(test_tzinfo))
return suite
Expand Down

0 comments on commit 238b4f6

Please sign in to comment.