A flake8 plugin checking for mocking issues.
Project description
flake8-patch
A flake8
plugin checking for mocking issues.
Currently reports the code PAT001
when assignments to imported objects are detected.
Bad code example
from some_module import SomeClass
def test_something():
SomeClass.some_method = lambda: 42
This is bad because SomeClass.some_method
might be used directly or indirectly in another test, which will break randomly depending on the execution order.
Good code example
from some_module import SomeClass
def test_something(mocker):
mocker.patch.object(SomeClass, "some_method", return_value=42)
This uses the mocker fixture from pytest-mock
to automatically unwind the patch after the test method runs.
Change Log
Unreleased
...
0.1.0 - 2020-10-02
Add PAT001: assignment to imported name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flake8-patch-0.1.0.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for flake8_patch-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b7fcf8672a30bf94b9053c1d45033951a22d395030c8d3ff41bfa678ebd276d |
|
MD5 | d04c665f1bbc8fa4c6efd7c7e96ef304 |
|
BLAKE2b-256 | 8b58bc114b9136d2aa7ca656644d958a04a548414ca8092fb8fd08e4c6ed4cf1 |