feat: implemented more tests
This commit is contained in:
parent
07a933c625
commit
02522ddbb6
@ -26,6 +26,7 @@ def error_handling(default: Any) -> Callable:
|
|||||||
return default
|
return default
|
||||||
|
|
||||||
self.logger.error(repr(e))
|
self.logger.error(repr(e))
|
||||||
|
|
||||||
return default
|
return default
|
||||||
|
|
||||||
return _wrapper
|
return _wrapper
|
||||||
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
27
tests/test_error_handling.py
Normal file
27
tests/test_error_handling.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user