feat: implemented more tests
This commit is contained in:
		| @@ -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() | ||||||
		Reference in New Issue
	
	Block a user