Skip to content

Commit 4b02fbf

Browse files
authored
Merge pull request #3711 from reubenmiller/chore-rf-framework-linting
test: fix system test formatting and linting
2 parents 36d4d52 + 1e3c0a5 commit 4b02fbf

File tree

9 files changed

+939
-274
lines changed

9 files changed

+939
-274
lines changed

tests/RobotFramework/.pylintrc

Lines changed: 653 additions & 0 deletions
Large diffs are not rendered by default.

tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py

Lines changed: 250 additions & 241 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
"""thin-edge.io library for Robot Framework"""
2+
23
# pylint: disable=invalid-name
34
from .ThinEdgeIO import ThinEdgeIO
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
robotframework-devicelibrary[docker] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.18.0
1+
robotframework-devicelibrary[docker] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.20.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
robotframework-devicelibrary[local] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.18.0
1+
robotframework-devicelibrary[local] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.20.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
robotframework-devicelibrary[ssh] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.18.0
1+
robotframework-devicelibrary[ssh] @ git+https://github.com/thin-edge/robotframework-devicelibrary.git@1.20.0
22
robotframework-sshlibrary~=3.8.0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
black~=24.4.2
1+
black~=25.1.0
22
invoke~=2.2.0
3-
pylint~=3.1.0
4-
robotframework-robocop~=6.1.1
3+
pylint~=3.3.7
4+
robotframework-robocop~=6.5.0

tests/RobotFramework/requirements/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
dateparser~=1.2.0
21
paho-mqtt~=1.6.1
32
python-dotenv~=1.0.0
43
robotframework~=7.0.0
5-
robotframework-c8y @ git+https://github.com/thin-edge/robotframework-c8y.git@0.43.1
4+
robotframework-c8y @ git+https://github.com/thin-edge/robotframework-c8y.git@0.45.0
65
robotframework-aws @ git+https://github.com/thin-edge/robotframework-aws.git@0.0.10
76
robotframework-debuglibrary~=2.5.0
87
robotframework-jsonlibrary~=0.5

tests/RobotFramework/tasks.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
import subprocess
1111
import time
1212
import datetime
13+
from typing import Any
1314

1415
import invoke
15-
from invoke import task
16+
from invoke.tasks import task
1617
from dotenv import load_dotenv
1718

1819

19-
def using_buildx(c: any, binary: str) -> bool:
20+
def using_buildx(c: Any, binary: str) -> bool:
2021
"""Detect if docker buildx is being used
2122
2223
Args:
@@ -40,14 +41,14 @@ class ColourFormatter(logging.Formatter):
4041
red = "\x1b[31;20m"
4142
bold_red = "\x1b[31;1m"
4243
reset = "\x1b[0m"
43-
format = "%(levelname)-8s %(message)s (%(filename)s:%(lineno)d)"
44+
template = "%(levelname)-8s %(message)s (%(filename)s:%(lineno)d)"
4445

4546
FORMATS = {
46-
logging.DEBUG: grey + format + reset,
47-
logging.INFO: grey + format + reset,
48-
logging.WARNING: yellow + format + reset,
49-
logging.ERROR: red + format + reset,
50-
logging.CRITICAL: bold_red + format + reset,
47+
logging.DEBUG: grey + template + reset,
48+
logging.INFO: grey + template + reset,
49+
logging.WARNING: yellow + template + reset,
50+
logging.ERROR: red + template + reset,
51+
logging.CRITICAL: bold_red + template + reset,
5152
}
5253

5354
def format(self, record):
@@ -138,12 +139,7 @@ def is_ci():
138139
return bool(os.getenv("CI"))
139140

140141

141-
@task
142-
def lint(c):
143-
"""Run linter"""
144-
c.run(f"{sys.executable} -m pylint libraries")
145-
146-
@task
142+
@task(aliases=["lint"])
147143
def lint_tests(c, threshold="W"):
148144
"""Run RobotFramework Test Linter and Formatter check
149145
@@ -154,18 +150,20 @@ def lint_tests(c, threshold="W"):
154150
print("Checking formatting of RobotFramework tests...", file=sys.stderr)
155151
c.run(f"{sys.executable} -m robocop check --threshold {threshold}")
156152

157-
@task(name="format")
158-
def formatcode(c):
159-
"""Format python code"""
160-
c.run(f"{sys.executable} -m black libraries")
153+
print("Checking linting of RobotFramework libraries...", file=sys.stderr)
154+
c.run(f"{sys.executable} -m pylint libraries")
161155

162-
@task
156+
157+
@task(aliases=["format"])
163158
def format_tests(c):
164-
"""Format RobotFramework tests
165-
"""
159+
"""Format RobotFramework tests"""
166160
print("Formatting of RobotFramework tests...", file=sys.stderr)
167161
c.run(f"{sys.executable} -m robocop format")
168162

163+
print("Formatting of RobotFramework libraries...", file=sys.stderr)
164+
c.run(f"{sys.executable} -m black .")
165+
166+
169167
@task(name="reports")
170168
def start_server(c, port=9000):
171169
"""Start simple webserver used to display the test reports"""
@@ -281,7 +279,13 @@ def use_local(c, arch="", package_type="deb"):
281279
},
282280
)
283281
def build(
284-
c, name="debian-systemd", cache=True, local=True, binary=None, arch="", build_options=""
282+
c,
283+
name="debian-systemd",
284+
cache=True,
285+
local=True,
286+
binary=None,
287+
arch="",
288+
build_options="",
285289
):
286290
"""Build the container integration test image
287291
@@ -394,8 +398,7 @@ def flake_finder(
394398

395399
if os.path.exists(outputdir):
396400
if not clean:
397-
# sys.exit(1)
398-
raise invoke.Exit(
401+
raise invoke.exceptions.Exit(
399402
(
400403
"ERROR: Output directory already exists. "
401404
f"Please use --clean if you want to remove it. dir={outputdir}"
@@ -425,7 +428,7 @@ def flake_finder(
425428
exclude=exclude,
426429
)
427430
passed.append(i)
428-
except invoke.exceptions.Failure as ex:
431+
except invoke.exceptions.Failure:
429432
failed.append(i)
430433

431434
duration_sec = time.monotonic() - duration_start

0 commit comments

Comments
 (0)