Test Name function validator (Flake8 plugin)
============================================
.. image:: https://github.com/bagerard/flake8-test-name/actions/workflows/github-actions.yml/badge.svg
:alt: Build status
:target: https://github.com/bagerard/flake8-test-name/actions/workflows/github-actions.yml
.. image:: https://coveralls.io/repos/github/bagerard/flake8-test-name/badge.svg
:alt: Coverage Status
:target: https://coveralls.io/github/bagerard/flake8-test-name
An extension for `Flake8 <https://github.com/PyCQA/flake8>`_ to make sure
that test function name follows a given convention
Plugin for Flake8
-----------------
When both Flake8 and ``flake8-test-name`` are installed, the plugin
will show up when displaying the version of ``flake8``:
.. code:: bash
$ flake8 --version
3.6.0 (flake8-test-name: 0.1.2, […]
Operation
---------
The hook assumes that your:
- test files are matching :code:`test_.*.py`
- test functions are starting with :code:`test_`
Any function matching these 2 conditions will be validated against your custom validator
Parameters
----------
This module can be configured in 2 ways.
First option is a regex using :code:`--test-func-name-validator-regex`:
.. code:: bash
$ flake8 myproject/tests/sample.py --test-func-name-validator-regex="test_funky_convention_.*" --select=TN101
>> myproject/tests/sample.py:14:1: TN101 test function name does not match the convention (test_invalid_method_sample)
Second option is with a python module containing a method named :code:`test_function_name_validator`.
Assuming you have a funky_validator.py file with the following content:
.. code:: python
def test_function_name_validator(func_name: str):
return func_name.startswith("test_funkyconvention")
You can then configure it using :code:`--test-func-name-validator-module`:
.. code:: bash
$ flake8 myproject/tests/sample.py --test-func-name-validator-module=./funky_validator.py --select=TN101
>> myproject/tests/sample.py:14:1: TN101 test function name does not match the convention (test_invalid_method_sample)
Error codes
-----------
This plugin is using the following error codes:
+----------------------------------------------------------------+
| Code | Error |
+-------+--------------------------------------------------------+
| TN101 | TN101 test function name does not match the convention |
+-------+--------------------------------------------------------+
Changes
-------
0.1.6 - 2023-10-03
``````````````````
* fix in options parser for flake8 > 6.0
0.1.5 - 2021-03-21
``````````````````
* minor refactoring and doc improvement
0.1.1 - 2021-03-19
``````````````````
* Initial release
Raw data
{
"_id": null,
"home_page": "https://github.com/bagerard/flake8-test-name",
"name": "flake8-test-name",
"maintainer": "Bastien Gerard",
"docs_url": null,
"requires_python": "",
"maintainer_email": "bast.gerard@gmail.com",
"keywords": "flake8 test name convention",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/ab/2d/c4835a370633996a04d0862f588b5dbfa66f3aea7e634a7442ff10a2bc8a/flake8-test-name-0.1.6.tar.gz",
"platform": null,
"description": "Test Name function validator (Flake8 plugin)\n============================================\n\n.. image:: https://github.com/bagerard/flake8-test-name/actions/workflows/github-actions.yml/badge.svg\n :alt: Build status\n :target: https://github.com/bagerard/flake8-test-name/actions/workflows/github-actions.yml\n\n.. image:: https://coveralls.io/repos/github/bagerard/flake8-test-name/badge.svg\n :alt: Coverage Status\n :target: https://coveralls.io/github/bagerard/flake8-test-name\n\nAn extension for `Flake8 <https://github.com/PyCQA/flake8>`_ to make sure\nthat test function name follows a given convention\n\n\nPlugin for Flake8\n-----------------\n\nWhen both Flake8 and ``flake8-test-name`` are installed, the plugin\nwill show up when displaying the version of ``flake8``:\n\n.. code:: bash\n\n $ flake8 --version\n 3.6.0 (flake8-test-name: 0.1.2, [\u2026]\n\n\nOperation\n---------\n\nThe hook assumes that your:\n\n- test files are matching :code:`test_.*.py`\n- test functions are starting with :code:`test_`\n\nAny function matching these 2 conditions will be validated against your custom validator\n\nParameters\n----------\n\nThis module can be configured in 2 ways.\nFirst option is a regex using :code:`--test-func-name-validator-regex`:\n\n.. code:: bash\n\n $ flake8 myproject/tests/sample.py --test-func-name-validator-regex=\"test_funky_convention_.*\" --select=TN101\n\n >> myproject/tests/sample.py:14:1: TN101 test function name does not match the convention (test_invalid_method_sample)\n\n\n\nSecond option is with a python module containing a method named :code:`test_function_name_validator`.\nAssuming you have a funky_validator.py file with the following content:\n\n.. code:: python\n\n def test_function_name_validator(func_name: str):\n return func_name.startswith(\"test_funkyconvention\")\n\nYou can then configure it using :code:`--test-func-name-validator-module`:\n\n.. code:: bash\n\n $ flake8 myproject/tests/sample.py --test-func-name-validator-module=./funky_validator.py --select=TN101\n\n >> myproject/tests/sample.py:14:1: TN101 test function name does not match the convention (test_invalid_method_sample)\n\nError codes\n-----------\n\nThis plugin is using the following error codes:\n\n+----------------------------------------------------------------+\n| Code | Error |\n+-------+--------------------------------------------------------+\n| TN101 | TN101 test function name does not match the convention |\n+-------+--------------------------------------------------------+\n\n\nChanges\n-------\n\n0.1.6 - 2023-10-03\n``````````````````\n* fix in options parser for flake8 > 6.0\n\n0.1.5 - 2021-03-21\n``````````````````\n* minor refactoring and doc improvement\n\n0.1.1 - 2021-03-19\n``````````````````\n* Initial release\n\n\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Invalid test name checker, plugin for flake8",
"version": "0.1.6",
"project_urls": {
"Homepage": "https://github.com/bagerard/flake8-test-name"
},
"split_keywords": [
"flake8",
"test",
"name",
"convention"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6ac9e1d62942f6f7446802aae688703283484c49faf6fa608c54f133cf2a5f9f",
"md5": "8ddd0c72348db04c031746056b3cfd5b",
"sha256": "e7be96848555a7b144ac5b1856a62b5bb96e56682489bb860fdbec79e2599a04"
},
"downloads": -1,
"filename": "flake8_test_name-0.1.6-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8ddd0c72348db04c031746056b3cfd5b",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 5156,
"upload_time": "2023-10-03T08:51:58",
"upload_time_iso_8601": "2023-10-03T08:51:58.084598Z",
"url": "https://files.pythonhosted.org/packages/6a/c9/e1d62942f6f7446802aae688703283484c49faf6fa608c54f133cf2a5f9f/flake8_test_name-0.1.6-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ab2dc4835a370633996a04d0862f588b5dbfa66f3aea7e634a7442ff10a2bc8a",
"md5": "023fb2158c920037e3753a622d264a83",
"sha256": "e22b8198dd8717fe50249668a4c521e02e4224ec04662c2029ca894efcf74bd0"
},
"downloads": -1,
"filename": "flake8-test-name-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "023fb2158c920037e3753a622d264a83",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8048,
"upload_time": "2023-10-03T08:51:59",
"upload_time_iso_8601": "2023-10-03T08:51:59.117766Z",
"url": "https://files.pythonhosted.org/packages/ab/2d/c4835a370633996a04d0862f588b5dbfa66f3aea7e634a7442ff10a2bc8a/flake8-test-name-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-03 08:51:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bagerard",
"github_project": "flake8-test-name",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "flake8-test-name"
}