What does Python – ‘-m’ stand for in ‘python -m unittest’?

What does Python – ‘-m’ stand for in ‘python -m unittest’? … here is a solution to the problem.

What does Python – ‘-m’ stand for in ‘python -m unittest’?

What does -m stand for in python -m unittest? The unittest unit test framework has other command-line options like –v -b -c -t but wondering what -m stands for? Is it part of UnitTest or other Python command-line options?

Solution

If you run python --help you will see:

-m mod : run library module as a script (terminates option list)

An explanation of what this means and the -m flag can be found here I’ve copied the important part below:

Properly designed modules usually do nothing but set up content (e.g., functions and types you can import), but they usually don’t have any visible side effects. That’s why you can execute import sys without any reaction.

However, some modules may provide something useful when run from the command line. Examples of this include venv, but also http.server or idlelib: all of these are regular modules that can be imported from other modules without side effects.

But when executed directly, they all do a few things (e.g., venv sets up a virtual environment, http.server runs a simple HTTP server, and idlelib runs IDLE). This is usually done with the following checks:

Related Problems and Solutions