Skip to content

Commit

Permalink
Simplify SunTimeException
Browse files Browse the repository at this point in the history
This is enough for an expection that just contains
a message ( https://stackoverflow.com/a/1319675 ).

To verify that it works as expected, the TestNoSun tests
are expanded to check the exception message.
  • Loading branch information
rfjakob committed Jul 11, 2024
1 parent 8053379 commit b9fe1a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions suntime/suntime.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@


class SunTimeException(Exception):

def __init__(self, message):
super(SunTimeException, self).__init__(message)
pass


class Sun:
Expand Down
4 changes: 2 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def setUp(self):

def test_get_sunrise_time(self):
# Test for no sunrise
with self.assertRaises(SunTimeException):
with self.assertRaisesRegex(SunTimeException, 'The sun'):
self.sun.get_sunrise_time(datetime(2024, 12, 21)) # Winter solstice in the northern hemisphere

def test_get_sunset_time(self):
# Test for no sunset
with self.assertRaises(SunTimeException):
with self.assertRaisesRegex(SunTimeException, 'The sun'):
self.sun.get_sunset_time(datetime(2024, 6, 21)) # Summer solstice in the northern hemisphere


Expand Down

0 comments on commit b9fe1a8

Please sign in to comment.