aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/kunit/kunit_config.py
diff options
context:
space:
mode:
authorDaniel Latypov <dlatypov@google.com>2022-05-09 13:49:09 -0700
committerShuah Khan <skhan@linuxfoundation.org>2022-05-16 13:22:36 -0600
commit0453f984a7b9458f0e469afb039f2841308b1bef (patch)
tree37cbf2c09f11c5b0482c7b8ffa096e6d48571307 /tools/testing/kunit/kunit_config.py
parentkunit: tool: minor cosmetic cleanups in kunit_parser.py (diff)
downloadlinux-dev-0453f984a7b9458f0e469afb039f2841308b1bef.tar.xz
linux-dev-0453f984a7b9458f0e469afb039f2841308b1bef.zip
kunit: tool: misc cleanups
This primarily comes from running pylint over kunit tool code and ignoring some warnings we don't care about. If we ever got a fully clean setup, we could add this to run_checks.py, but we're not there yet. Fix things like * Drop unused imports * check `is None`, not `== None` (see PEP 8) * remove redundant parens around returns * remove redundant `else` / convert `elif` to `if` where appropriate * rename make_arch_qemuconfig() param to base_kunitconfig (this is the name used in the subclass, and it's a better one) * kunit_tool_test: check the exit code for SystemExit (could be 0) Signed-off-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: David Gow <davidgow@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/kunit/kunit_config.py')
-rw-r--r--tools/testing/kunit/kunit_config.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/tools/testing/kunit/kunit_config.py b/tools/testing/kunit/kunit_config.py
index ca33e4b7bcc5..75a8dc1683d4 100644
--- a/tools/testing/kunit/kunit_config.py
+++ b/tools/testing/kunit/kunit_config.py
@@ -20,16 +20,15 @@ class KconfigEntry:
def __str__(self) -> str:
if self.value == 'n':
- return r'# CONFIG_%s is not set' % (self.name)
- else:
- return r'CONFIG_%s=%s' % (self.name, self.value)
+ return f'# CONFIG_{self.name} is not set'
+ return f'CONFIG_{self.name}={self.value}'
class KconfigParseError(Exception):
"""Error parsing Kconfig defconfig or .config."""
-class Kconfig(object):
+class Kconfig:
"""Represents defconfig or .config specified using the Kconfig language."""
def __init__(self) -> None:
@@ -49,7 +48,7 @@ class Kconfig(object):
if a.value == 'n':
continue
return False
- elif a.value != b:
+ if a.value != b:
return False
return True
@@ -91,6 +90,5 @@ def parse_from_string(blob: str) -> Kconfig:
if line[0] == '#':
continue
- else:
- raise KconfigParseError('Failed to parse: ' + line)
+ raise KconfigParseError('Failed to parse: ' + line)
return kconfig