28 lines
639 B
Python
28 lines
639 B
Python
|
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()
|