You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

flake8-patch

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flake8-patch

A flake8 plugin checking for mocking issues.


Maintainers
1

Readme

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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc