We need to do a unit test for the exception
Is there a way to deliberately cause specific exceptions such as EOFError
and ZeroDivisionError
?
In the unittest module, You must write TestCase.assertRaises().
For example,
import mymod
class MyTestCase(unittest.TestCase):
def test1(self):
self.assertRaises(ZeroDivisionError, mymod.myfunc)
Together
If a function receives a factor,
self.assertRaises(ZeroDivisionError, mymod.myfunc, arg1, arg2)
You can pass the factor as shown in .
584 PHP ssh2_scp_send fails to send files as intended
576 Who developed the "avformat-59.dll" that comes with FFmpeg?
623 Uncaught (inpromise) Error on Electron: An object could not be cloned
578 Understanding How to Configure Google API Key
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.