osmith submitted this change.
testenv: various small syntax tweaks
Change-Id: Ib07577c34b90abd936e005ca4f20c4e50fabb3a3
---
M .ruff.toml
M _testenv/testenv.py
M _testenv/testenv/__init__.py
M _testenv/testenv/podman.py
M _testenv/testenv/testenv_cfg.py
M _testenv/testenv/testsuite.py
6 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/.ruff.toml b/.ruff.toml
index d8fc4db..ff68e24 100644
--- a/.ruff.toml
+++ b/.ruff.toml
@@ -10,14 +10,9 @@
"DTZ004", # https://docs.astral.sh/ruff/rules/call-datetime-utcfromtimestamp/
"DTZ005", # https://docs.astral.sh/ruff/rules/call-datetime-now-without-tzinfo/
"DTZ007", # https://docs.astral.sh/ruff/rules/call-datetime-strptime-without-zone/
- "FURB105", # https://docs.astral.sh/ruff/rules/print-empty-string/
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports/
"LOG015", # https://docs.astral.sh/ruff/rules/root-logger-call/
- "PIE808", # https://docs.astral.sh/ruff/rules/unnecessary-range-start/
"PLC0206", # https://docs.astral.sh/ruff/rules/dict-index-missing-items/
"PLW0602", # https://docs.astral.sh/ruff/rules/global-variable-not-assigned/
"RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/
- "SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if/
- "SIM103", # https://docs.astral.sh/ruff/rules/needless-bool/
- "SIM118", # https://docs.astral.sh/ruff/rules/in-dict-keys/
]
diff --git a/_testenv/testenv.py b/_testenv/testenv.py
index 29bf56e..01f6d95 100755
--- a/_testenv/testenv.py
+++ b/_testenv/testenv.py
@@ -138,7 +138,7 @@
testenv.podman.stop()
sys.exit(2)
except KeyboardInterrupt:
- print("") # new line
+ print() # new line
test = testenv.testsuite.get_current_test()
if test:
logging.critical(f"^C during {test}")
diff --git a/_testenv/testenv/__init__.py b/_testenv/testenv/__init__.py
index ed302ab..5a24c10 100644
--- a/_testenv/testenv/__init__.py
+++ b/_testenv/testenv/__init__.py
@@ -329,7 +329,7 @@
}
def __init__(self):
- for color in self.colors.keys():
+ for color in self.colors:
env_var = f"TESTENV_COLOR_{color.upper()}"
if env_var in os.environ:
self.colors[color] = os.environ.get(env_var)
diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py
index 4fcb905..0293712 100644
--- a/_testenv/testenv/podman.py
+++ b/_testenv/testenv/podman.py
@@ -57,13 +57,11 @@
def image_build(check_existing=True):
- if check_existing:
- if image_exists() and image_up_to_date():
- logging.debug(f"Podman image is up-to-date: {image_name}")
- if testenv.args.force:
- logging.debug("Building anyway since --force was used")
- else:
- return
+ if check_existing and image_exists() and image_up_to_date():
+ logging.debug(f"Podman image is up-to-date: {image_name}")
+ if not testenv.args.force:
+ return
+ logging.debug("Building anyway since --force was used")
logging.info(f"Building podman image: {image_name}")
testenv.cmd.run(
@@ -348,10 +346,7 @@
return False
cmd = ["podman", "ps", "-q", "--filter", f"name={container_name}"]
- if not subprocess.run(cmd, capture_output=True, text=True, check=False).stdout:
- return False
-
- return True
+ return bool(subprocess.run(cmd, capture_output=True, text=True, check=False).stdout)
def stop(restart=False):
diff --git a/_testenv/testenv/testenv_cfg.py b/_testenv/testenv/testenv_cfg.py
index 93ffa5d..cf7896e 100644
--- a/_testenv/testenv/testenv_cfg.py
+++ b/_testenv/testenv/testenv_cfg.py
@@ -87,7 +87,7 @@
qemu_required = False
for basename, cfg in cfgs.items():
- for section in cfg.keys():
+ for section in cfg:
if "qemu" in cfg[section]:
qemu_supported = True
if cfg[section]["qemu"] == "required":
@@ -171,7 +171,7 @@
exit_error_readme()
for section in cfg:
- for key in cfg[section].keys():
+ for key in cfg[section]:
valid = keys_valid_component
if section == "testsuite":
valid = keys_valid_testsuite
diff --git a/_testenv/testenv/testsuite.py b/_testenv/testenv/testsuite.py
index 6a85cd5..b1bd8a8 100644
--- a/_testenv/testenv/testsuite.py
+++ b/_testenv/testenv/testsuite.py
@@ -210,7 +210,7 @@
logging.debug("Waiting until test has stopped...")
- for i in range(0, 1200):
+ for i in range(1200):
time.sleep(0.1)
if not os.path.exists(path):
return
To view, visit change 43306. To unsubscribe, or for help writing mail filters, visit settings.