71 lines
2.6 KiB
Diff
71 lines
2.6 KiB
Diff
From 5666877a0fe2cb9d99b1bca82d2d531887c22e4e Mon Sep 17 00:00:00 2001
|
|
From: Miroslav Lisik <mlisik@redhat.com>
|
|
Date: Wed, 8 Jun 2022 16:57:29 +0200
|
|
Subject: [PATCH] Python 3.11 related fixes
|
|
|
|
fix test_failed function in test tools
|
|
fix enum value in test fixture
|
|
fix test case mocking
|
|
---
|
|
pcs_test/tier0/cli/test_nvset.py | 3 ++-
|
|
pcs_test/tier0/lib/commands/test_ticket.py | 2 +-
|
|
pcs_test/tools/case_analysis.py | 13 ++++++-------
|
|
3 files changed, 9 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/pcs_test/tier0/cli/test_nvset.py b/pcs_test/tier0/cli/test_nvset.py
|
|
index 93a96e7a..ad44f2a1 100644
|
|
--- a/pcs_test/tier0/cli/test_nvset.py
|
|
+++ b/pcs_test/tier0/cli/test_nvset.py
|
|
@@ -149,7 +149,8 @@ class NvsetDtoListToLines(TestCase):
|
|
|
|
def fixture_dto_list(self):
|
|
return [
|
|
- self.fixture_dto(in_effect) for in_effect in CibRuleInEffectStatus
|
|
+ self.fixture_dto(in_effect.value)
|
|
+ for in_effect in CibRuleInEffectStatus
|
|
]
|
|
|
|
def test_expired_included(self):
|
|
diff --git a/pcs_test/tier0/lib/commands/test_ticket.py b/pcs_test/tier0/lib/commands/test_ticket.py
|
|
index 5459582a..3e7b7310 100644
|
|
--- a/pcs_test/tier0/lib/commands/test_ticket.py
|
|
+++ b/pcs_test/tier0/lib/commands/test_ticket.py
|
|
@@ -95,7 +95,7 @@ class CreateTest(TestCase):
|
|
)
|
|
|
|
|
|
-@patch_commands("get_constraints", mock.Mock)
|
|
+@patch_commands("get_constraints", mock.Mock())
|
|
class RemoveTest(TestCase):
|
|
@patch_commands("ticket.remove_plain", mock.Mock(return_value=1))
|
|
@patch_commands(
|
|
diff --git a/pcs_test/tools/case_analysis.py b/pcs_test/tools/case_analysis.py
|
|
index 49fd1ee8..6d311548 100644
|
|
--- a/pcs_test/tools/case_analysis.py
|
|
+++ b/pcs_test/tools/case_analysis.py
|
|
@@ -10,15 +10,14 @@ def _list2reason(test, exc_list):
|
|
def test_failed(test):
|
|
# Borrowed from
|
|
# https://stackoverflow.com/questions/4414234/getting-pythons-unittest-results-in-a-teardown-method/39606065#39606065
|
|
- # for Python versions 2.7 to 3.6
|
|
- if hasattr(test, "_outcome"): # Python 3.4+
|
|
- # these 2 methods have no side effects
|
|
+ # for Python versions 3.4 to 3.11
|
|
+ if hasattr(test._outcome, "errors"):
|
|
+ # Python 3.4 - 3.10 (These 2 methods have no side effects)
|
|
result = test.defaultTestResult()
|
|
test._feedErrorsToResult(result, test._outcome.errors)
|
|
- else: # Python 3.2 - 3.3 or 3.0 - 3.1 and 2.7
|
|
- result = getattr(
|
|
- test, "_outcomeForDoCleanups", test._resultForDoCleanups
|
|
- )
|
|
+ else:
|
|
+ # Python 3.11+
|
|
+ result = test._outcome.result
|
|
|
|
return _list2reason(test, result.errors) or _list2reason(
|
|
test, result.failures
|
|
--
|
|
2.35.3
|
|
|