Tom's wiki

Python

The Python programming language.

Learn

Notes

Testing

The standard unit testing module is unittest. The file naming convention is test_*.py.

Test template:

import unittest

class TestFoo(unittest.TestCase):
    def test_foo(self) -> None:
        self.assertEqual(1, 2)

if __name__ == "__main__":
    unittest.main()

A popular alternative is pytest.

Virtual environment

A directory that contains an isolated runtime and local pip dependencies. Should be created for each project instead of using the global pip.

Tooling