Skip to content

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

Python 3

(un)fold
Snippets
General
Libs

Linux/bash

(un)fold
Guides
Scripts

Git

(un)fold

C/C++

(un)fold

Video

(un)fold

Databases

(un)fold

Misc

(un)fold

Windows

(un)fold

Mac

(un)fold

SW recommendations

(un)fold

(Angular) Dart

(un)fold
Clone this wiki locally