Skip to content

Commit 3525983

Browse files
committed
Fix test skipping.
Signed-off-by: Jelmer de Wolde <jelmer.de.wolde@alliander.com>
1 parent 0123634 commit 3525983

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

alliander_tests/src/alliander_tests/tests/test_camera.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# SPDX-FileCopyrightText: Alliander N. V.
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
54
import random
65
import subprocess
76

@@ -14,12 +13,11 @@
1413
camera = Camera(random.choice(["realsense", "zed"]), (0, 0, 0.5))
1514
PLATFORMS = [camera]
1615

17-
system_architecture = subprocess.getoutput("dpkg --print-architecture")
18-
if system_architecture != "amd64":
19-
pytest.skip(
20-
f"Camera tests skipped, not supported on {system_architecture} yet.",
21-
allow_module_level=True,
22-
)
16+
17+
def skip_if_not_amd64() -> None:
18+
"""Skip the test if the system architecture is not amd64."""
19+
if subprocess.getoutput("dpkg --print-architecture") != "amd64":
20+
pytest.skip("Test skipped, not supported on non-amd64 system yet.")
2321

2422

2523
def test_color_image_published(timeout: int) -> None:
@@ -28,6 +26,7 @@ def test_color_image_published(timeout: int) -> None:
2826
Args:
2927
timeout (int): The timeout in seconds.
3028
"""
29+
skip_if_not_amd64()
3130
assert_for_message(Image, f"/{camera.namespace}/color/image_raw", timeout=timeout)
3231

3332

@@ -37,6 +36,7 @@ def test_color_camera_info_published(timeout: int) -> None:
3736
Args:
3837
timeout (int): The timeout in seconds.
3938
"""
39+
skip_if_not_amd64()
4040
assert_for_message(
4141
CameraInfo, f"/{camera.namespace}/color/camera_info", timeout=timeout
4242
)
@@ -48,6 +48,7 @@ def test_depth_image_published(timeout: int) -> None:
4848
Args:
4949
timeout (int): The timeout in seconds.
5050
"""
51+
skip_if_not_amd64()
5152
assert_for_message(
5253
Image, f"/{camera.namespace}/depth/image_rect_raw", timeout=timeout
5354
)
@@ -59,6 +60,7 @@ def test_depth_camera_info_published(timeout: int) -> None:
5960
Args:
6061
timeout (int): The timeout in seconds.
6162
"""
63+
skip_if_not_amd64()
6264
assert_for_message(
6365
CameraInfo, f"/{camera.namespace}/depth/camera_info", timeout=timeout
6466
)

0 commit comments

Comments
 (0)