feat: implemented more tests

This commit is contained in:
Hazel 2024-04-25 15:00:54 +02:00
parent 07a933c625
commit 02522ddbb6
3 changed files with 28 additions and 0 deletions

View File

@ -26,6 +26,7 @@ def error_handling(default: Any) -> Callable:
return default
self.logger.error(repr(e))
return default
return _wrapper

0
tests/__init__.py Normal file
View File

View File

@ -0,0 +1,27 @@
import unittest
from python_sponsorblock import SponsorBlock, error_handling
from python_sponsorblock.exceptions import SponsorBlockError
SILENT_WORKS = "silent_works"
@error_handling(default=SILENT_WORKS)
def raise_error(self):
raise SponsorBlockError("Error")
class TestErrorHandling(unittest.TestCase):
def test_silent(self):
s = SponsorBlock(silent=True)
self.assertEqual(raise_error(s), SILENT_WORKS)
def test_not_silent(self):
s = SponsorBlock(silent=False)
with self.assertRaises(SponsorBlockError):
raise_error(s)
if __name__ == "__main__":
unittest.main()