Skip to content

Commit 4cae256

Browse files
pb8odianpopa
authored andcommitted
Disable Pylint's redefined-outer-name in tests
It creates too many false positives in conftest.py [See this page][1] [1]: https://stackoverflow.com/questions/46089480/pytest-fixtures-redefining-name-from-outer-scope-pylint Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 6915c82 commit 4cae256

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

tests/conftest.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Pytest fixtures and redefined-outer-name don't mix well. Disable it.
5+
# pylint:disable=redefined-outer-name
6+
37
"""Imported by pytest at the start of every test session.
48
59
# Fixture Goals
@@ -178,8 +182,6 @@ def dump(self, result):
178182

179183
def init_microvm(root_path, bin_cloner_path, fc_binary=None, jailer_binary=None):
180184
"""Auxiliary function for instantiating a microvm and setting it up."""
181-
# pylint: disable=redefined-outer-name
182-
# The fixture pattern causes a pylint false positive for that rule.
183185
microvm_id = str(uuid.uuid4())
184186

185187
# Update permissions for custom binaries.
@@ -255,8 +257,6 @@ def test_fc_session_root_path():
255257
@pytest.fixture
256258
def test_session_tmp_path(test_fc_session_root_path):
257259
"""Yield a random temporary directory. Destroyed on teardown."""
258-
# pylint: disable=redefined-outer-name
259-
# The fixture pattern causes a pylint false positive for that rule.
260260

261261
tmp_path = tempfile.mkdtemp(prefix=test_fc_session_root_path)
262262
yield tmp_path
@@ -285,8 +285,6 @@ def bin_cloner_path(test_fc_session_root_path):
285285
It's necessary because Python doesn't interface well with the `clone()`
286286
syscall directly.
287287
"""
288-
# pylint: disable=redefined-outer-name
289-
# The fixture pattern causes a pylint false positive for that rule.
290288
cloner_bin_path = os.path.join(test_fc_session_root_path, "newpid_cloner")
291289
_gcc_compile("host_tools/newpid_cloner.c", cloner_bin_path)
292290
yield cloner_bin_path
@@ -295,8 +293,6 @@ def bin_cloner_path(test_fc_session_root_path):
295293
@pytest.fixture(scope="session")
296294
def bin_vsock_path(test_fc_session_root_path):
297295
"""Build a simple vsock client/server application."""
298-
# pylint: disable=redefined-outer-name
299-
# The fixture pattern causes a pylint false positive for that rule.
300296
vsock_helper_bin_path = os.path.join(test_fc_session_root_path, "vsock_helper")
301297
_gcc_compile("host_tools/vsock_helper.c", vsock_helper_bin_path)
302298
yield vsock_helper_bin_path
@@ -305,7 +301,6 @@ def bin_vsock_path(test_fc_session_root_path):
305301
@pytest.fixture(scope="session")
306302
def change_net_config_space_bin(test_fc_session_root_path):
307303
"""Build a binary that changes the MMIO config space."""
308-
# pylint: disable=redefined-outer-name
309304
change_net_config_space_bin = os.path.join(
310305
test_fc_session_root_path, "change_net_config_space"
311306
)
@@ -327,8 +322,6 @@ def bin_seccomp_paths(test_fc_session_root_path):
327322
* a jailed binary that follows the seccomp rules;
328323
* a jailed binary that breaks the seccomp rules.
329324
"""
330-
# pylint: disable=redefined-outer-name
331-
# The fixture pattern causes a pylint false positive for that rule.
332325
seccomp_build_path = os.path.join(
333326
test_fc_session_root_path, build_tools.CARGO_RELEASE_REL_PATH
334327
)
@@ -367,8 +360,6 @@ def bin_seccomp_paths(test_fc_session_root_path):
367360
@pytest.fixture(scope="session")
368361
def uffd_handler_paths(test_fc_session_root_path):
369362
"""Build UFFD handler binaries."""
370-
# pylint: disable=redefined-outer-name
371-
# The fixture pattern causes a pylint false positive for that rule.
372363
uffd_build_path = os.path.join(
373364
test_fc_session_root_path, build_tools.CARGO_RELEASE_REL_PATH
374365
)
@@ -402,9 +393,6 @@ def uffd_handler_paths(test_fc_session_root_path):
402393
@pytest.fixture()
403394
def microvm(test_fc_session_root_path, bin_cloner_path):
404395
"""Instantiate a microvm."""
405-
# pylint: disable=redefined-outer-name
406-
# The fixture pattern causes a pylint false positive for that rule.
407-
408396
# Make sure the necessary binaries are there before instantiating the
409397
# microvm.
410398
vm = init_microvm(test_fc_session_root_path, bin_cloner_path)
@@ -455,8 +443,6 @@ def test_microvm_any(request, microvm):
455443
test cases for each test that depends on this fixture, each receiving a
456444
microvm instance with a different microvm image.
457445
"""
458-
# pylint: disable=redefined-outer-name
459-
# The fixture pattern causes a pylint false positive for that rule.
460446

461447
MICROVM_S3_FETCHER.init_vm_resources(request.param, microvm)
462448
yield microvm
@@ -471,8 +457,6 @@ def test_multiple_microvms(test_fc_session_root_path, context, bin_cloner_path):
471457
of the guest image used to spawn a microvm and the number of microvms
472458
to spawn.
473459
"""
474-
# pylint: disable=redefined-outer-name
475-
# The fixture pattern causes a pylint false positive for that rule.
476460
microvms = []
477461
(microvm_resources, how_many) = context
478462

0 commit comments

Comments
 (0)