do not use deprecated unittest features (#2019410)

This commit is contained in:
Lukas Zaoral 2021-11-03 14:56:16 +01:00 committed by Lukáš Zaoral
parent 88d824c351
commit 5ea1012980
No known key found for this signature in database
GPG Key ID: 39157506DD67752D
2 changed files with 104 additions and 1 deletions

View File

@ -0,0 +1,98 @@
From 41728025340a02643085adcbcecf986ad8667209 Mon Sep 17 00:00:00 2001
From: Scott Talbert <swt@techie.net>
Date: Tue, 17 Aug 2021 20:39:00 -0400
Subject: [PATCH] Fix warnings when running tests
---
tests/memory_mgmt_test.py | 4 ++--
tests/reload_test.py | 4 ++--
tests/setopt_lifecycle_test.py | 1 +
tests/setopt_test.py | 8 ++++----
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/tests/memory_mgmt_test.py b/tests/memory_mgmt_test.py
index 416fd4c..ec841f2 100644
--- a/tests/memory_mgmt_test.py
+++ b/tests/memory_mgmt_test.py
@@ -297,7 +297,7 @@ class MemoryMgmtTest(unittest.TestCase):
gc.collect()
after_object_count = len(gc.get_objects())
- self.assert_(after_object_count <= before_object_count + 1000, 'Grew from %d to %d objects' % (before_object_count, after_object_count))
+ self.assertTrue(after_object_count <= before_object_count + 1000, 'Grew from %d to %d objects' % (before_object_count, after_object_count))
c.close()
def test_form_bufferptr_memory_leak_gh267(self):
@@ -317,7 +317,7 @@ class MemoryMgmtTest(unittest.TestCase):
gc.collect()
after_object_count = len(gc.get_objects())
- self.assert_(after_object_count <= before_object_count + 1000, 'Grew from %d to %d objects' % (before_object_count, after_object_count))
+ self.assertTrue(after_object_count <= before_object_count + 1000, 'Grew from %d to %d objects' % (before_object_count, after_object_count))
c.close()
def do_data_refcounting(self, option):
diff --git a/tests/reload_test.py b/tests/reload_test.py
index 3f037a1..e6c1fbc 100644
--- a/tests/reload_test.py
+++ b/tests/reload_test.py
@@ -14,6 +14,6 @@ class ReloadTest(unittest.TestCase):
reload_fn = reload
except NameError:
# python 3
- import imp
- reload_fn = imp.reload
+ import importlib
+ reload_fn = importlib.reload
reload_fn(pycurl)
diff --git a/tests/setopt_lifecycle_test.py b/tests/setopt_lifecycle_test.py
index 1adb70c..eacedc8 100644
--- a/tests/setopt_lifecycle_test.py
+++ b/tests/setopt_lifecycle_test.py
@@ -17,6 +17,7 @@ from . import util
setup_module, teardown_module = appmanager.setup(('app', 8380))
class TestString(str):
+ __test__ = False
def __del__(self):
self.replace('1', '2')
#print self
diff --git a/tests/setopt_test.py b/tests/setopt_test.py
index 29ae2f0..472cf34 100644
--- a/tests/setopt_test.py
+++ b/tests/setopt_test.py
@@ -58,13 +58,13 @@ class SetoptTest(unittest.TestCase):
io = util.BytesIO()
self.curl.setopt(self.curl.WRITEDATA, io)
self.curl.perform()
- self.assertEquals(util.b('foo'), io.getvalue())
+ self.assertEqual(util.b('foo'), io.getvalue())
self.curl.unsetopt(self.curl.HTTPHEADER)
io = util.BytesIO()
self.curl.setopt(self.curl.WRITEDATA, io)
self.curl.perform()
- self.assertEquals(util.b(''), io.getvalue())
+ self.assertEqual(util.b(''), io.getvalue())
def test_set_httpheader_none(self):
self.curl.setopt(self.curl.HTTPHEADER, ('x-test: foo',))
@@ -72,13 +72,13 @@ class SetoptTest(unittest.TestCase):
io = util.BytesIO()
self.curl.setopt(self.curl.WRITEDATA, io)
self.curl.perform()
- self.assertEquals(util.b('foo'), io.getvalue())
+ self.assertEqual(util.b('foo'), io.getvalue())
self.curl.setopt(self.curl.HTTPHEADER, None)
io = util.BytesIO()
self.curl.setopt(self.curl.WRITEDATA, io)
self.curl.perform()
- self.assertEquals(util.b(''), io.getvalue())
+ self.assertEqual(util.b(''), io.getvalue())
@util.min_libcurl(7, 37, 0)
def test_proxyheader_list(self):
--
2.31.1

View File

@ -23,13 +23,15 @@
Name: python-%{modname}
Version: 7.44.1
Release: 3%{?dist}
Release: 4%{?dist}
Summary: A Python interface to libcurl
License: LGPLv2+ or MIT
URL: http://pycurl.io/
Source0: https://files.pythonhosted.org/packages/47/f9/c41d6830f7bd4e70d5726d26f8564538d08ca3a7ac3db98b325f94cdcb7f/pycurl-%{version}.tar.gz
# do not use deprecated unittest features (#2019410)
Patch1: 0001-Fix-warnings-when-running-tests.patch
# drop link-time vs. run-time TLS backend check (#1446850)
Patch2: 0002-python-pycurl-7.43.0-tls-backend.patch
@ -159,6 +161,9 @@ rm -fv tests/fake-curl/libcurl/*.so
%endif
%changelog
* Wed Nov 03 2021 Lukáš Zaoral <lzaoral@redhat.com> - 7.44.1-4
- do not use deprecated unittest features (#2019410)
* Fri Sep 17 2021 Scott Talbert <swt@techie.net> - 7.44.1-3
- Cleanup test overrides & enable more tests