Path: blob/main/tests/integration_tests/style/test_python.py
1958 views
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1# SPDX-License-Identifier: Apache-2.02"""Tests ensuring codebase style compliance for Python."""34import framework.utils as utils567def test_python_style():8"""Fail if there's misbehaving Python style in the test system."""9# List of linter commands that should be executed for each file10linter_cmds = [11# Pylint12'python3 -m pylint --jobs=0 --persistent=no --score=no ' \13'--output-format=colorized --attr-rgx="[a-z_][a-z0-9_]{1,30}$" ' \14'--argument-rgx="[a-z_][a-z0-9_]{1,35}$" ' \15'--variable-rgx="[a-z_][a-z0-9_]{1,30}$" --disable=' \16'bad-continuation,fixme,too-many-instance-attributes,import-error,' \17'too-many-locals,too-many-arguments',1819# pycodestyle20'python3 -m pycodestyle --show-pep8 --show-source --exclude=../build',2122# pydocstyle23"python3 -m pydocstyle --explain --source"]2425# Get all *.py files from the project26python_files = utils.get_files_from(27find_path="..",28pattern="*.py",29exclude_names=["build", ".kernel"])3031# Assert if somehow no python files were found32assert len(python_files) != 03334# Run commands35utils.run_cmd_list_async([36f"{cmd} {fname}" for cmd in linter_cmds for fname in python_files37])383940