test_method_mismatch: optimize to simplify lines
import os
-MODULE_PATH = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), "..", "py3status", "modules"
+MODULE_PATH = os.path.join(os.path.dirname(
+ os.path.abspath(__file__)), "..", "py3status", "modules"
)
SKIP_FILES = ["__init__.py", "i3pystatus.py"]
-def check_method_mismatch():
- files = [x for x in os.listdir(MODULE_PATH) if x not in SKIP_FILES]
+def test_method_mismatch():
errors = []
-
- for _file in sorted(files):
- if _file.endswith(".py"):
+ for _file in sorted(os.listdir(MODULE_PATH)):
+ if _file.endswith(".py") and _file not in SKIP_FILES:
with open(os.path.join(MODULE_PATH, _file)) as f:
- _self = "def {}(self".format(_file[:-3])
- if _self not in f.read():
- errors.append((_self[4:-5], _file))
- return errors
-
-
-def test_method_mismatch():
- errors = check_method_mismatch()
+ name = _file[:-3]
+ if "def {}(self".format(name) not in f.read():
+ errors.append((name, _file))
if errors:
line = "Method mismatched error(s) detected!\n\n"
for error in errors:
