How To Install python-mock on Debian 9

In this tutorial we learn how to install python-mock on Debian 9. python-mock is Mocking and Testing Library

Introduction

In this tutorial we learn how to install python-mock on Debian 9.

What is python-mock

python-mock is:

mock provides a core mock.Mock class that is intended to reduce the need to create a host of trivial stubs throughout your test suite. After performing an action, you can make assertions about which methods / attributes were used and arguments they were called with. You can also specify return values and set specific attributes in the normal way.

There are three methods to install python-mock on Debian 9. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python-mock Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python-mock using apt-get by running the following command:

sudo apt-get -y install python-mock

Install python-mock Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python-mock using apt by running the following command:

sudo apt -y install python-mock

Install python-mock Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python-mock using aptitude by running the following command:

sudo aptitude -y install python-mock

How To Uninstall python-mock on Debian 9

To uninstall only the python-mock package we can use the following command:

sudo apt-get remove python-mock

Uninstall python-mock And Its Dependencies

To uninstall python-mock and its dependencies that are no longer needed by Debian 9, we can use the command below:

sudo apt-get -y autoremove python-mock

Remove python-mock Configurations and Data

To remove python-mock configuration and data from Debian 9 we can use the following command:

sudo apt-get -y purge python-mock

Remove python-mock configuration, data, and all of its dependencies

We can use the following command to remove python-mock configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-mock

Dependencies

python-mock have the following dependencies:

References

Summary

In this tutorial we learn how to install python-mock package on Debian 9 using different package management tools: apt, apt-get and aptitude.