Resolves: rhbz#bz2093935

- Python 3.11 related fixes
This commit is contained in:
Miroslav Lisik 2022-06-09 11:01:20 +02:00
parent f8c8ea2492
commit d172d46e44
2 changed files with 77 additions and 2 deletions

View File

@ -0,0 +1,70 @@
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

View File

@ -1,6 +1,6 @@
Name: pcs
Version: 0.11.2
Release: 1%{?dist}
Release: 2%{?dist}
# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/
# https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses
# GPLv2: pcs
@ -49,6 +49,7 @@ Source101: https://github.com/ClusterLabs/pcs-web-ui/releases/download/%{ui_comm
# pcs patches: <= 200
# Patch0: name.patch
Patch0: bz2093935-01-Python-3.11-related-fixes.patch
# ui patches: >200
# Patch201: name.patch
@ -252,7 +253,7 @@ update_times_patch %{PATCH202}
# patch pcs sources
%autosetup -S git -n %{pcs_source_name} -N
%autopatch -p1 -M 200
# update_times_patch %%{PATCH0}
update_times_patch %{PATCH0}
# prepare dirs/files necessary for building all bundles
# -----------------------------------------------------
@ -425,6 +426,10 @@ run_all_tests
%license pyagentx_LICENSE.txt
%changelog
* Thu Jun 09 2022 Miroslav Lisik <mlisik@redhat.com> - 0.11.2-2
- Python 3.11 related fixes
- Resolves: rhbz#bz2093935
* Fri Feb 04 2022 Miroslav Lisik <mlisik@redhat.com> - 0.11.2-1
- Rebased to latest upstream sources (see CHANGELOG.md)
- Updated pcs-web-ui