Provides checking for non-existent mock methods and properties
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.
You can install or upgrade verve-flake8-mock with these commands:
$ pip install verve-flake8-mock $ pip install --upgrade verve-flake8-mock
Plugin for Flake8
When both flake8 3.5.0 and verve-flake8-mock are installed, the plugin is available in flake8:
$ flake8 --version 3.5.0 (verve-flake8-mock: 0.4, pyflakes: 0.8.1)
Once you run flake8, you can have something like:
$ flake8 test_file.py test_file.py:55:5: M201 called_once is a non-existent mock property test_file.py:56:5: M200 called_once_with is a non-existent mock method
- Alejandro Gabriel Pereira is the original author.
- Ania Warzecha has rewritten it for flake8 3 and with support for more methods
- Forked by Verve to verve-flake8-mock
- Added has_calls to checked methods
- Added a check for not existent properties on mocks
- Added compatibility for flake8 3.x
- Added tests
- Don’t warn on assert_not_called, assert_called or assert_called_once.
- Use ASCII only in README.rst
- Add Python 3 compatibility.
- First release.
- First dev release.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size verve_flake8_mock-0.4-py3-none-any.whl (10.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View hashes|
|Filename, size verve-flake8-mock-0.4.tar.gz (3.5 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for verve_flake8_mock-0.4-py3-none-any.whl