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 files starting with test_ and check any functions or methods starting with test_ against your validator.

Changes

0.1.4 - 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.5.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

flake8_test_name-0.1.5-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: flake8-test-name-0.1.5.tar.gz
  • Upload date:
  • Size: 7.8 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.5.tar.gz
Algorithm Hash digest
SHA256 a17e6b6eaa8106867da9a2b01eedbd8eca204cb9ab25902c409f69381856ff28
MD5 f0a34e73fed106b5dce4eb94b255565e
BLAKE2b-256 5c7d5bc23eb84859a18f812693ed10e4d2077b54ce39ce77e73e8c3a71b6cf3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flake8_test_name-0.1.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.1 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.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 de502a668a9381b69d2b1a4f05244e73eb1a126e2326aed68d6c3488737cec4e
MD5 b29022a59d38da2749bb81d6b8b342d9
BLAKE2b-256 a60d4f78a26bc90bb38c3d4b2cd434d9378b7199e796a716fa176465b04d5601

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