Skip to content

deprecated-mock-import (UP026)

Added in v0.0.206 · Related issues · View source

Derived from the pyupgrade linter.

Fix is always available.

What it does

Checks for imports of the mock module that should be replaced with unittest.mock.

Why is this bad?

Since Python 3.3, mock has been a part of the standard library as unittest.mock. The mock package is deprecated; use unittest.mock instead.

Example

import mock

Use instead:

from unittest import mock

Options

This rule will not trigger if the mock import is required by the isort configuration.

References