python-uranium/Uranium-5.6.0-pytest8.patch
Miro Hrončok e07acba2f5 Fix build with pytest 8
- Fixes: rhbz#2275262
2024-04-16 12:52:42 +02:00

53 lines
2.3 KiB
Diff

From dd2c31bc0f38d11c8351d89fae3d92cd12da885e Mon Sep 17 00:00:00 2001
From: Remco Burema <r.burema@ultimaker.com>
Date: Wed, 21 Feb 2024 11:39:49 +0100
Subject: [PATCH 1/3] Protobuf version mismatch caused tests,builds to fail.
---
1 file changed, 1 insertion(+)
diff --git a/tests/conftest.py b/tests/conftest.py
index 4fcd4cefd..4f500fabc 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -59,3 +59,17 @@ def upgrade_manager(application):
upgrade_manager = VersionUpgradeManager(application)
return upgrade_manager
+def pytest_collection_modifyitems(items):
+ """ Modifies test items in place to ensure test classes run in a given order.
+ See: https://stackoverflow.com/questions/70738211/run-pytest-classes-in-custom-order/70758938#70758938
+ """
+ CLASS_ORDER = ["TestActiveToolProxy"] # All classes that need to be run in-order, in that order -- all others will run _before_.
+ class_mapping = {item: item.cls.__name__ for item in items}
+
+ sorted_items = items.copy()
+ # Iteratively move tests of each class to the end of the test queue
+ for class_ in CLASS_ORDER:
+ sorted_items = [it for it in sorted_items if class_mapping[it] != class_] + [
+ it for it in sorted_items if class_mapping[it] == class_
+ ]
+ items[:] = sorted_items
From cd4eb2cf8c450c23a3f2d42619ee36ec93d49a6d Mon Sep 17 00:00:00 2001
From: Remco Burema <r.burema@ultimaker.com>
Date: Wed, 21 Feb 2024 16:22:24 +0100
Subject: [PATCH 3/3] Not all our tests are classes.
---
tests/conftest.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 4f500fabc..d26f2545a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -64,7 +64,7 @@ def pytest_collection_modifyitems(items):
See: https://stackoverflow.com/questions/70738211/run-pytest-classes-in-custom-order/70758938#70758938
"""
CLASS_ORDER = ["TestActiveToolProxy"] # All classes that need to be run in-order, in that order -- all others will run _before_.
- class_mapping = {item: item.cls.__name__ for item in items}
+ class_mapping = {item: (item.cls.__name__ if item.cls else "") for item in items}
sorted_items = items.copy()
# Iteratively move tests of each class to the end of the test queue