Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tests/integration_tests/style/test_python.py
1958 views
1
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
# SPDX-License-Identifier: Apache-2.0
3
"""Tests ensuring codebase style compliance for Python."""
4
5
import framework.utils as utils
6
7
8
def test_python_style():
9
"""Fail if there's misbehaving Python style in the test system."""
10
# List of linter commands that should be executed for each file
11
linter_cmds = [
12
# Pylint
13
'python3 -m pylint --jobs=0 --persistent=no --score=no ' \
14
'--output-format=colorized --attr-rgx="[a-z_][a-z0-9_]{1,30}$" ' \
15
'--argument-rgx="[a-z_][a-z0-9_]{1,35}$" ' \
16
'--variable-rgx="[a-z_][a-z0-9_]{1,30}$" --disable=' \
17
'bad-continuation,fixme,too-many-instance-attributes,import-error,' \
18
'too-many-locals,too-many-arguments',
19
20
# pycodestyle
21
'python3 -m pycodestyle --show-pep8 --show-source --exclude=../build',
22
23
# pydocstyle
24
"python3 -m pydocstyle --explain --source"]
25
26
# Get all *.py files from the project
27
python_files = utils.get_files_from(
28
find_path="..",
29
pattern="*.py",
30
exclude_names=["build", ".kernel"])
31
32
# Assert if somehow no python files were found
33
assert len(python_files) != 0
34
35
# Run commands
36
utils.run_cmd_list_async([
37
f"{cmd} {fname}" for cmd in linter_cmds for fname in python_files
38
])
39
40