Invalid test name checker, plugin for flake8
Project description
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, […]
Parameters
This module can be configured in 2 ways: –test-func-name-validator-module={path_to_a_python_file} or –test-func-name-validator-regex={regex_pattern}
E.g usage with the 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)
E.g usage with the module:: Since regex aren’t a good fit for all the use case, you can also provide your own validator as a python file with a function 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 the plugin with:
$ 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:
Test function name validation |
|
TN101 |
TN101 test function name does not match the convention |
Operation
The plugin will go through all files, look for directories named “tests”, and validate method starting with test_ against your validator.
Changes
0.1.2 - 2021-03-21
minor refactoring and doc improvement
0.1.1 - 2021-03-19
Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8-test-name-0.1.2.tar.gz
.
File metadata
- Download URL: flake8-test-name-0.1.2.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7331918064aa2256c894bb008211d5dd10056801c8c119f691dc521c41ecf7b6 |
|
MD5 | 4a5b604aaba51cef192d401148c46d58 |
|
BLAKE2b-256 | 532bfd26edbc0f2676401829bd3f1caa9c25788c1987868dd359918031c93483 |
File details
Details for the file flake8_test_name-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: flake8_test_name-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 509f2f766e57613ecbfabacf3d6be26f614a0e04cc240fecb44e74e25fbcfbe1 |
|
MD5 | a47f5e05b503beedf3057785259c1581 |
|
BLAKE2b-256 | c192cb16b7e8d13d6a7741c6232974f5da174921447c9357813946e88bb760c6 |