Test Name function validator (Flake8 plugin)
An extension for 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:
$ flake8 --version
3.6.0 (flake8-test-name: 0.1.2, […]
Operation
The hook assumes that your:
test files are matching
test_.*.pytest functions are starting with
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 --test-func-name-validator-regex:
$ 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 test_function_name_validator.
Assuming you have a funky_validator.py file with the following content:
def test_function_name_validator(func_name: str):
return func_name.startswith("test_funkyconvention")
You can then configure it using --test-func-name-validator-module:
$ 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
Metadata
Release files for flake8-test-name 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8-test-name-0.1.6.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_test_name-0.1.6-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 13.2 kB
Release files / flake8-test-name-0.1.6.tar.gz
| Download URL | flake8-test-name-0.1.6.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e22b8198dd8717fe50249668a4c521e02e4224ec04662c2029ca894efcf74bd0
|
|
BLAKE2b-256 checksum How to use checksums |
ab2dc4835a370633996a04d0862f588b5dbfa66f3aea7e634a7442ff10a2bc8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / flake8_test_name-0.1.6-py2.py3-none-any.whl
| Download URL | flake8_test_name-0.1.6-py2.py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e7be96848555a7b144ac5b1856a62b5bb96e56682489bb860fdbec79e2599a04
|
|
BLAKE2b-256 checksum How to use checksums |
6ac9e1d62942f6f7446802aae688703283484c49faf6fa608c54f133cf2a5f9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|