Skip to main content

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

Metadata

Release files for flake8-patch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-patch 0.1.0
File Size Uploaded Provenance Actions
flake8-patch-0.1.0.tar.gz 3.5 kB Without provenance Details for flake8-patch-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flake8-patch 0.1.0
File Interpreter ABI Platform Actions
flake8_patch-0.1.0-py3-none-any.whl Python 3 none any Details for flake8_patch-0.1.0-py3-none-any.whl

Total release size: 8.0 kB

Release files / flake8-patch-0.1.0.tar.gz

Download URL flake8-patch-0.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bfbcf45ef04914bbb85e2352b7335fe38dc7c0a8b98fdd18d7965e5447da9446
BLAKE2b-256 checksum
How to use checksums
179fed810cb8745d6115aa6bc871d328a36f0b0efa40bb6e221627156f0cb094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.0 CPython/3.8.2 Linux/5.4.0-48-generic

Release files / flake8_patch-0.1.0-py3-none-any.whl

Download URL flake8_patch-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b7fcf8672a30bf94b9053c1d45033951a22d395030c8d3ff41bfa678ebd276d
BLAKE2b-256 checksum
How to use checksums
8b58bc114b9136d2aa7ca656644d958a04a548414ca8092fb8fd08e4c6ed4cf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.0 CPython/3.8.2 Linux/5.4.0-48-generic

Security for flake8-patch 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page