-
Notifications
You must be signed in to change notification settings - Fork 0
unittests
holzkohlengrill edited this page Dec 15, 2023
·
2 revisions
import unittest
def is_prime(x):
return x == 2 or all([x % 2 != 0] + [x % i != 0 for i in range(3, max(x - 1, 3), 2)])
class TestMagic(unittest.TestCase):
def test_prime(self): # each method must start with test
self.assertTrue(is_prime(5))
if __name__ == '__main__':
unittest.main()
See also here
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License *.
Code (snippets) are licensed under a MIT License *.
* Unless stated otherwise