Skip to content

Commit

Permalink
test: disable pylint's redefined-outer-name
Browse files Browse the repository at this point in the history
This lint unilaterally forbids shadowing. However, this clashes with
pytest fixtures in a great many places: To use a fixture a test function
needs to have an argument that matches the fixture's name. However, if
the fixture is defined in the same file as its usage, then this will
trigger pylint's redfined-outer-name. Since this is a very common
pattern, disable this lint.

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Oct 9, 2023
1 parent fb17dcc commit 536f234
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 24 deletions.
2 changes: 0 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# Pytest fixtures and redefined-outer-name don't mix well. Disable it.
# pylint:disable=redefined-outer-name
# We import some fixtures that are unused. Disable that too.
# pylint:disable=unused-import

Expand Down
2 changes: 0 additions & 2 deletions tests/host_tools/ip_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# pylint:disable=redefined-outer-name

"""
Each microVM needs to have a unique IP on the host network, or there will be
conflicts.
Expand Down
2 changes: 0 additions & 2 deletions tests/integration_tests/functional/test_drives.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Tests for guest-side operations on /drives resources."""

# pylint:disable=redefined-outer-name

import os
from subprocess import check_output

Expand Down
2 changes: 0 additions & 2 deletions tests/integration_tests/functional/test_rng.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Tests for the virtio-rng device"""

# pylint:disable=redefined-outer-name

import pytest

from framework.properties import global_props
Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/performance/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# Pytest fixtures and redefined-outer-name don't mix well. Disable it.
# pylint:disable=redefined-outer-name

"""Fixtures for performance tests"""

import json
Expand Down
2 changes: 0 additions & 2 deletions tests/integration_tests/performance/test_boottime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Tests that ensure the boot time to init process is within spec."""

# pylint:disable=redefined-outer-name

import re
import time

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Test that the process startup time up to socket bind is within spec."""

# pylint: disable=redefined-outer-name

import os
import time

Expand Down
2 changes: 0 additions & 2 deletions tests/integration_tests/security/test_jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
"""Tests that verify the jailer's behavior."""

# pylint: disable=redefined-outer-name

import functools
import http.client as http_client
import os
Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/security/test_seccomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def test_seccomp_ls(bin_seccomp_paths):
"""
Assert that the seccomp filter denies an unallowed syscall.
"""
# pylint: disable=redefined-outer-name
# pylint: disable=subprocess-run-check
# The fixture pattern causes a pylint false positive for that rule.

Expand Down Expand Up @@ -135,7 +134,6 @@ def test_advanced_seccomp(bin_seccomp_paths):
binary, denies the malicious demo binary and that an empty allowlist
denies everything.
"""
# pylint: disable=redefined-outer-name
# pylint: disable=subprocess-run-check
# The fixture pattern causes a pylint false positive for that rule.

Expand Down Expand Up @@ -272,7 +270,6 @@ def test_seccomp_rust_panic(bin_seccomp_paths):
Test that the Firecracker filters allow a Rust panic to run its
course without triggering a seccomp violation.
"""
# pylint: disable=redefined-outer-name
# pylint: disable=subprocess-run-check
# The fixture pattern causes a pylint false positive for that rule.

Expand Down
3 changes: 0 additions & 3 deletions tests/integration_tests/security/test_vulnerabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@

VULN_DIR = "/sys/devices/system/cpu/vulnerabilities"

# This lint doesnt work well with fixtures
# pylint:disable=redefined-outer-name


def configure_microvm(
factory,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/style/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_python_pylint():
'--variable-rgx="[a-z_][a-z0-9_]{1,30}$" --disable='
"fixme,too-many-instance-attributes,import-error,"
"too-many-locals,too-many-arguments,consider-using-f-string,"
"consider-using-with,implicit-str-concat,line-too-long,"
"consider-using-with,implicit-str-concat,line-too-long,redefined-outer-name,"
"broad-exception-raised,duplicate-code tests tools .buildkite/*.py"
)
run(
Expand Down

0 comments on commit 536f234

Please sign in to comment.