Skip to content

Commit f034136

Browse files
committed
Apply pylint suggestions to external tests
1 parent 23b1ff3 commit f034136

1 file changed

Lines changed: 28 additions & 27 deletions

File tree

test/unit/external_repository/test_external_repo.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""
1616
Test external repositories with codechecker
1717
"""
18-
from logging import debug
1918
import logging
2019
import os
2120
import shutil
@@ -26,6 +25,7 @@
2625

2726
class TestImplDepExternalDep(TestBase):
2827
"""Test external repositories with codechecker"""
28+
2929
# Set working directory
3030
__test_path__ = os.path.dirname(os.path.abspath(__file__))
3131
BAZEL_BIN_DIR = os.path.join("bazel-bin")
@@ -47,13 +47,14 @@ def setUpClass(cls):
4747
try:
4848
shutil.copy("../../../.bazelversion", ".bazelversion")
4949
shutil.copy(
50-
"../../../.bazelversion", "third_party/my_lib/.bazelversion")
51-
52-
except:
50+
"../../../.bazelversion", "third_party/my_lib/.bazelversion"
51+
)
52+
# pylint: disable=broad-exception-caught
53+
except Exception:
5354
logging.debug("No bazel version set, using system default")
5455
_, stdout, _ = cls.run_command("bazel --version")
55-
cls.BAZEL_VERSION = stdout.split(' ')[2].strip()
56-
logging.debug("Using Bazel", cls.BAZEL_VERSION)
56+
cls.BAZEL_VERSION = stdout.split(" ")[2].strip()
57+
logging.debug("Using Bazel %s", cls.BAZEL_VERSION)
5758

5859
@final
5960
@classmethod
@@ -66,50 +67,50 @@ def tearDownClass(cls):
6667
cls.run_command("bazel clean")
6768
try:
6869
os.remove(".bazelversion")
69-
except:
70+
# pylint: disable=broad-exception-caught
71+
except Exception:
7072
pass
7173
try:
7274
os.remove("third_party/my_lib/.bazelversion")
73-
except:
75+
# pylint: disable=broad-exception-caught
76+
except Exception:
7477
pass
7578

7679
def test_compile_commands_external_lib(self):
7780
"""Test: bazel build :compile_commands_isystem"""
78-
ret, _, _ = self.run_command(
79-
"bazel build :compile_commands_isystem")
81+
ret, _, _ = self.run_command("bazel build :compile_commands_isystem")
8082
self.assertEqual(ret, 0)
8183
comp_json_file = os.path.join(
82-
self.BAZEL_BIN_DIR, # pyright: ignore[reportOptionalOperand]
84+
self.BAZEL_BIN_DIR, # pyright: ignore
8385
"compile_commands_isystem",
84-
"compile_commands.json")
86+
"compile_commands.json",
87+
)
8588

8689
# The ~override part is a consquence of using Bzlmod.
87-
if self.BAZEL_VERSION.startswith("6"): # type: ignore
90+
if self.BAZEL_VERSION.startswith("6"): # type: ignore
8891
pattern1 = "-isystem external/external_lib~override/include"
89-
pattern2 = "-isystem " + \
90-
"bazel-out/k8-fastbuild/bin/external/external_lib~override/include"
92+
pattern2 = (
93+
"-isystem bazel-out/k8-fastbuild/bin/external/"
94+
"external_lib~override/include"
95+
)
9196
else:
9297
pattern1 = "-isystem external/external_lib~/include"
93-
pattern2 = "-isystem " + \
94-
"bazel-out/k8-fastbuild/bin/external/external_lib~/include"
98+
pattern2 = (
99+
"-isystem bazel-out/k8-fastbuild/bin/external/"
100+
"external_lib~/include"
101+
)
95102

96-
self.assertTrue(self.contains_regex_in_file(
97-
comp_json_file,
98-
pattern1))
99-
self.assertTrue(self.contains_regex_in_file(
100-
comp_json_file,
101-
pattern2))
103+
self.assertTrue(self.contains_regex_in_file(comp_json_file, pattern1))
104+
self.assertTrue(self.contains_regex_in_file(comp_json_file, pattern2))
102105

103106
def test_codechecker_external_lib(self):
104107
"""Test: bazel build :codechecker_external_deps"""
105-
ret, _, _ = self.run_command(
106-
"bazel build :codechecker_external_deps")
108+
ret, _, _ = self.run_command("bazel build :codechecker_external_deps")
107109
self.assertEqual(ret, 0)
108110

109111
def test_per_file_external_lib(self):
110112
"""Test: bazel build :per_file_external_deps"""
111-
ret, _, _ = self.run_command(
112-
"bazel build :per_file_external_deps")
113+
ret, _, _ = self.run_command("bazel build :per_file_external_deps")
113114
self.assertEqual(ret, 0)
114115

115116

0 commit comments

Comments
 (0)