flake8-mock


Nameflake8-mock JSON
Version 0.4 PyPI version JSON
download
home_pagehttps://github.com/aleGpereira/flake8-mock
SummaryProvides checking for non-existent mock methods
upload_time2023-07-07 10:02:13
maintainer
docs_urlNone
authorAlejandro Pereira
requires_python
licenseGNU
keywords flake8 mock testing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Flake8 Mock plugin
==================

Remember that a mock's job is to say, "You got it, boss" whenever anyone calls
it. It will do real work, like raising an exception, when one of its
convenience methods is called, like ``assert_called_once_with``. But it won't
do real work when you call a method that only *resembles* a convenience method,
such as ``assert_called_once`` (no ``_with``!). Sometimes developers may not
notice that they are using a non-existent mock method, because they are not
getting an output error telling them so. And for some reason they can also
forget to verify that the test cases fail before writing implementation code.

This plugin checks for possible non-existent mock methods when you run
``flake8``, the Python code checker.

Inspired by http://engineeringblog.yelp.com/2015/02/assert_called_once-threat-or-menace.html.


Installation
------------

You can install or upgrade ``flake8-mock`` with these commands::

  $ pip install flake8-mock
  $ pip install --upgrade flake8-mock


List of non-existent methods checked
------------------------------------

    * ``assert_calls``
    * ``not_called``
    * ``called_once``
    * ``called_once_with``


Plugin for Flake8
-----------------

When both ``flake8`` and ``flake8-mock`` are installed, the plugin is
available in ``flake8``::

    $ flake8 --version
    5.0.4 (flake8-mock: 0.4, ...)


Example output
--------------

Once you run flake8, you can have something like::

    $ flake8 test_file.py
    test_file.py:27:1: M001 assert_calls is a non-existent mock method.
    test_file.py:28:1: M001 called_once_with is a non-existent mock method.
    test_file.py:39:1: M001 not_called is a non-existent mock method.
    test_file.py:40:1: M001 assert_called is a non-existent mock method.

Credits
-------
    * `Alejandro Gabriel Pereira <https://github.com/aleGpereira>`_ is the main author.
    * `Nejc Zupan <https://github.com/zupo>`_ (`Niteo <https://niteo.co>`_) provided the idea
      and proof-reading.

Collaborators
-------------
    * `John Vandenberg <https://github.com/jayvdb>`_
    * `Tom Prince <https://github.com/tomprince>`_
    * `Gasper Vozel <https://github.com/karantan>`_
    * `Bjørnar Myrheim <https://github.com/myrheimb>`_


Changes
-------

0.4 (05-12-2023)
````````````````
* Fix compatibility with flake8 >= 5.0.0.

0.3 (09-10-2016)
````````````````
* Don't warn on `assert_not_called`, `assert_called` or `assert_called_once`.
* Use ASCII only in README.rst

0.2 (12-16-2015)
````````````````
* Add Python 3 compatibility.

0.1 (10-20-2015)
````````````````
* First release.

0.1dev0 (10-19-2015)
````````````````````
* First dev release.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aleGpereira/flake8-mock",
    "name": "flake8-mock",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "flake8,mock,testing",
    "author": "Alejandro Pereira",
    "author_email": "alepereira.dev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2a/18/39ccc52955b94cd61c8719292753ef4fd74d79c8d572b97e61de3a56beeb/flake8-mock-0.4.tar.gz",
    "platform": null,
    "description": "Flake8 Mock plugin\n==================\n\nRemember that a mock's job is to say, \"You got it, boss\" whenever anyone calls\nit. It will do real work, like raising an exception, when one of its\nconvenience methods is called, like ``assert_called_once_with``. But it won't\ndo real work when you call a method that only *resembles* a convenience method,\nsuch as ``assert_called_once`` (no ``_with``!). Sometimes developers may not\nnotice that they are using a non-existent mock method, because they are not\ngetting an output error telling them so. And for some reason they can also\nforget to verify that the test cases fail before writing implementation code.\n\nThis plugin checks for possible non-existent mock methods when you run\n``flake8``, the Python code checker.\n\nInspired by http://engineeringblog.yelp.com/2015/02/assert_called_once-threat-or-menace.html.\n\n\nInstallation\n------------\n\nYou can install or upgrade ``flake8-mock`` with these commands::\n\n  $ pip install flake8-mock\n  $ pip install --upgrade flake8-mock\n\n\nList of non-existent methods checked\n------------------------------------\n\n    * ``assert_calls``\n    * ``not_called``\n    * ``called_once``\n    * ``called_once_with``\n\n\nPlugin for Flake8\n-----------------\n\nWhen both ``flake8`` and ``flake8-mock`` are installed, the plugin is\navailable in ``flake8``::\n\n    $ flake8 --version\n    5.0.4 (flake8-mock: 0.4, ...)\n\n\nExample output\n--------------\n\nOnce you run flake8, you can have something like::\n\n    $ flake8 test_file.py\n    test_file.py:27:1: M001 assert_calls is a non-existent mock method.\n    test_file.py:28:1: M001 called_once_with is a non-existent mock method.\n    test_file.py:39:1: M001 not_called is a non-existent mock method.\n    test_file.py:40:1: M001 assert_called is a non-existent mock method.\n\nCredits\n-------\n    * `Alejandro Gabriel Pereira <https://github.com/aleGpereira>`_ is the main author.\n    * `Nejc Zupan <https://github.com/zupo>`_ (`Niteo <https://niteo.co>`_) provided the idea\n      and proof-reading.\n\nCollaborators\n-------------\n    * `John Vandenberg <https://github.com/jayvdb>`_\n    * `Tom Prince <https://github.com/tomprince>`_\n    * `Gasper Vozel <https://github.com/karantan>`_\n    * `Bj\u00f8rnar Myrheim <https://github.com/myrheimb>`_\n\n\nChanges\n-------\n\n0.4 (05-12-2023)\n````````````````\n* Fix compatibility with flake8 >= 5.0.0.\n\n0.3 (09-10-2016)\n````````````````\n* Don't warn on `assert_not_called`, `assert_called` or `assert_called_once`.\n* Use ASCII only in README.rst\n\n0.2 (12-16-2015)\n````````````````\n* Add Python 3 compatibility.\n\n0.1 (10-20-2015)\n````````````````\n* First release.\n\n0.1dev0 (10-19-2015)\n````````````````````\n* First dev release.\n",
    "bugtrack_url": null,
    "license": "GNU",
    "summary": "Provides checking for non-existent mock methods",
    "version": "0.4",
    "project_urls": {
        "Homepage": "https://github.com/aleGpereira/flake8-mock"
    },
    "split_keywords": [
        "flake8",
        "mock",
        "testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cbe8b2447852d1ffa97675869ceea3588f87a0a56a0e37c65ae660f5ea827f00",
                "md5": "cef43eec59befb10c753c04326590a2e",
                "sha256": "a67c3d22b2e7873c72d3f01d3eb5d06405cd09dc1abea74a0bf6fcf29095e8e6"
            },
            "downloads": -1,
            "filename": "flake8_mock-0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cef43eec59befb10c753c04326590a2e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10516,
            "upload_time": "2023-07-07T10:02:11",
            "upload_time_iso_8601": "2023-07-07T10:02:11.553948Z",
            "url": "https://files.pythonhosted.org/packages/cb/e8/b2447852d1ffa97675869ceea3588f87a0a56a0e37c65ae660f5ea827f00/flake8_mock-0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a1839ccc52955b94cd61c8719292753ef4fd74d79c8d572b97e61de3a56beeb",
                "md5": "987d6c3081ad32dc8fff2c269d092f9d",
                "sha256": "4a05bac5f66e77661994880dd050705132d19000f17d928a894dfd92d55d4867"
            },
            "downloads": -1,
            "filename": "flake8-mock-0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "987d6c3081ad32dc8fff2c269d092f9d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10241,
            "upload_time": "2023-07-07T10:02:13",
            "upload_time_iso_8601": "2023-07-07T10:02:13.944429Z",
            "url": "https://files.pythonhosted.org/packages/2a/18/39ccc52955b94cd61c8719292753ef4fd74d79c8d572b97e61de3a56beeb/flake8-mock-0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-07 10:02:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aleGpereira",
    "github_project": "flake8-mock",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "flake8-mock"
}
        
Elapsed time: 0.10897s