Skip to main content

Invalid test name checker, plugin for flake8

Project description

Build status Coverage Status

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.3 - 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

flake8-test-name-0.1.3.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

flake8_test_name-0.1.3-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flake8-test-name-0.1.3.tar.gz.

File metadata

  • Download URL: flake8-test-name-0.1.3.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

Hashes for flake8-test-name-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ade0443c81a5f9407c24e813a266363f6e76643ce96cfbd928a7e846ae910c77
MD5 492f3cb1e3e07146919795191a839555
BLAKE2b-256 b53822682c88d3c607f0f3182a76ce062bdb60bcc9d6e073c74aeb3e3bae30f3

See more details on using hashes here.

File details

Details for the file flake8_test_name-0.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: flake8_test_name-0.1.3-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

Hashes for flake8_test_name-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7b17f300d7a26f56d2cc6124724e1561d274e87935160caef600d807f32cd8eb
MD5 71ba44c0527cf6d1aa3e523c15fb02bb
BLAKE2b-256 71d9f9ce4bf389596a3671251f6458feaab3982eaadd037b7aefdd0ad001ed3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page