use python3_sitelib macro for meson upgrade and fix test failure

This commit is contained in:
panxiaohe 2021-07-22 16:37:57 +08:00
parent ffdf1db57b
commit 4e5474d4af
5 changed files with 367 additions and 53 deletions

View File

@ -1,47 +0,0 @@
From 925182370146907c51712d77bc026177f0644425 Mon Sep 17 00:00:00 2001
From: panxiaohe <panxiaohe@huawei.com>
Date: Sat, 22 May 2021 15:21:50 +0800
Subject: [PATCH] fix test failure of test_atoms and test_overrides_gtk
---
tests/test_atoms.py | 2 +-
tests/test_overrides_gtk.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/test_atoms.py b/tests/test_atoms.py
index a74db38..a896b3a 100644
--- a/tests/test_atoms.py
+++ b/tests/test_atoms.py
@@ -22,7 +22,7 @@ def is_X11():
@unittest.skipUnless(Gdk, 'Gdk not available')
-@unittest.skipIf(Gdk._version == "4.0", 'Gdk4 doesn\'t have GdkAtom')
+#@unittest.skipIf(Gdk._version == "4.0", 'Gdk4 doesn\'t have GdkAtom')
class TestGdkAtom(unittest.TestCase):
def test_create(self):
atom = Gdk.Atom.intern('my_string', False)
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index ff3acba..cded5fe 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -36,7 +36,7 @@ def gtkver():
Gtk.get_micro_version())
-GTK4 = (Gtk._version == "4.0")
+GTK4 = (Gtk_version == "4.0")
@contextlib.contextmanager
@@ -2794,7 +2794,7 @@ class TestContainer(unittest.TestCase):
self.assertEqual(fill, False)
self.assertEqual(padding, 21)
-
+@unittest.skipUnless(Gtk, 'Gtk not available')
def test_button_focus_on_click():
b = Gtk.Button()
b.set_focus_on_click(True)
--
1.8.3.1

View File

@ -1,16 +1,20 @@
Name: pygobject3
Version: 3.38.0
Release: 2
Release: 3
Summary: Provides bindings for GObject based libraries
License: LGPLv2+ and MIT
URL: https://wiki.gnome.org/Projects/PyGObject
Source0: https://download.gnome.org/sources/pygobject/3.38/pygobject-%{version}.tar.xz
Patch0: fix-test-failure-of-test_atoms-and-test_overrides_gtk.patch
Patch0: tests-fix-tests-with-glib-master.patch
Patch1: tests-Remove-usage-of-some-deprecated-unittest-metho.patch
Patch2: tests-fix-test-with-glib-2.68-re-GLocalFile.patch
BuildRequires: glib2-devel >= 2.48.0 gobject-introspection-devel >= 1.46.0
BuildRequires: meson cairo-gobject-devel python3-pytest
BuildRequires: meson cairo-gobject-devel
BuildRequires: python3-devel >= 3.4 python3-cairo-devel >= 1.11.1
#for test suite
BuildRequires: python3-pytest gtk3 dbus-x11 dejavu-fonts xorg-x11-server
%description
PyGObject is a Python package which provides bindings for GObject based libraries such as
@ -56,7 +60,7 @@ This package contains files required to embed PyGObject
%meson_install
%check
%{__python3} setup.py test
xvfb-run %{__python3} setup.py test
%pre
@ -74,9 +78,10 @@ This package contains files required to embed PyGObject
%doc NEWS
%dir %{python3_sitearch}/gi
%{python3_sitearch}/gi/*
%exclude %{python3_sitearch}/gi/_gi_cairo*.so
%{python3_sitearch}/pygtkcompat/
%{python3_sitearch}/PyGObject-*.egg-info
%exclude %{python3_sitearch}/gi/_gi_cairo*.so
%{python3_sitelib}/gi/*
%{python3_sitelib}/pygtkcompat/
%files devel
%{_includedir}/pygobject-3.0/pygobject.h
@ -85,6 +90,12 @@ This package contains files required to embed PyGObject
%{_libdir}/pkgconfig/pygobject-3.0.pc
%changelog
* Tue Jul 27 2021 panxiaohe <panxiaohe@huawei.com> - 3.38.0-3
- use python3_sitelib macro for meson upgrade
- add BuildRequires for testsuite
- tests: Remove usage of some deprecated unittest methods
- tests: fix test with glib 2.68 re GLocalFile
* Sat Jun 19 2021 panxiaohe <panxiaohe@huawei.com> - 3.38.0-2
- enable check test suite

View File

@ -0,0 +1,293 @@
From ebc0eed6f9838253ae6fcaa51695136611c98298 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Fri, 6 Nov 2020 16:02:43 +0100
Subject: [PATCH] tests: Remove usage of some deprecated unittest methods
---
tests/__init__.py | 4 ----
tests/test_gi.py | 36 ++++++++++++++++++------------------
tests/test_gio.py | 4 ++--
tests/test_overrides_gdk.py | 4 ++--
tests/test_overrides_glib.py | 32 ++++++++++++++++----------------
tests/test_overrides_gtk.py | 18 +++++++++---------
6 files changed, 47 insertions(+), 51 deletions(-)
diff --git a/tests/__init__.py b/tests/__init__.py
index 3497667..e6dd333 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,6 +1,5 @@
import os
import sys
-import unittest
import signal
import subprocess
import atexit
@@ -8,9 +7,6 @@ import warnings
def init_test_environ():
- # this was renamed in Python 3, provide backwards compatible name
- unittest.TestCase.assertRegexpMatches = unittest.TestCase.assertRegex
- unittest.TestCase.assertRaisesRegexp = unittest.TestCase.assertRaisesRegex
def dbus_launch_session():
if os.name == "nt" or sys.platform == "darwin":
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 2cabe02..5e7d0e3 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2248,22 +2248,22 @@ class TestStructure(unittest.TestCase):
self.assertRaises(TypeError, GIMarshallingTests.Union.method)
def test_repr(self):
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.PointerStruct()),
r"<GIMarshallingTests.PointerStruct object at 0x[^\s]+ "
r"\(void at 0x[^\s]+\)>")
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.SimpleStruct()),
r"<GIMarshallingTests.SimpleStruct object at 0x[^\s]+ "
r"\(void at 0x[^\s]+\)>")
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.Union()),
r"<GIMarshallingTests.Union object at 0x[^\s]+ "
r"\(GIMarshallingTestsUnion at 0x[^\s]+\)>")
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.BoxedStruct()),
r"<GIMarshallingTests.BoxedStruct object at 0x[^\s]+ "
r"\(GIMarshallingTestsBoxedStruct at 0x[^\s]+\)>")
@@ -2399,13 +2399,13 @@ class TestGObject(unittest.TestCase):
self.assertEqual(new_object.__grefcount__, 1)
def test_repr(self):
- self.assertRegexpMatches(
+ self.assertRegex(
repr(GIMarshallingTests.Object(int=42)),
r"<GIMarshallingTests.Object object at 0x[^\s]+ "
r"\(GIMarshallingTestsObject at 0x[^\s]+\)>")
def test_nongir_repr(self):
- self.assertRegexpMatches(
+ self.assertRegex(
repr(Gio.File.new_for_path("")),
r"<__gi__.GLocalFile object at 0x[^\s]+ "
r"\(GLocalFile at 0x[^\s]+\)>")
@@ -3208,7 +3208,7 @@ class TestDeprecation(unittest.TestCase):
self.assertEqual(len(warn), 3)
self.assertTrue(
issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(
+ self.assertRegex(
str(warn[0].message),
".*GLib.IO_STATUS_ERROR.*GLib.IOStatus.ERROR.*")
@@ -3244,8 +3244,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, 1, 2, 3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*a, b, c.*')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*a, b, c.*')
def test_deprecated_init_no_keywords_out_of_order(self):
def init(self, **kwargs):
@@ -3257,8 +3257,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, 2, 1, 3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*b, a, c.*')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*b, a, c.*')
def test_deprecated_init_ignored_keyword(self):
def init(self, **kwargs):
@@ -3272,8 +3272,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, 1, 2, 3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*a, b, c.*')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*a, b, c.*')
def test_deprecated_init_with_aliases(self):
def init(self, **kwargs):
@@ -3288,8 +3288,8 @@ class TestDeprecation(unittest.TestCase):
fn(self, a=1, bb=2, cc=3)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*keyword.*"bb, cc".*deprecated.*"b, c" respectively')
+ self.assertRegex(str(warn[0].message),
+ '.*keyword.*"bb, cc".*deprecated.*"b, c" respectively')
def test_deprecated_init_with_defaults(self):
def init(self, **kwargs):
@@ -3303,6 +3303,6 @@ class TestDeprecation(unittest.TestCase):
fn(self, a=1)
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*relying on deprecated non-standard defaults.*'
- 'explicitly use: b=2, c=3')
+ self.assertRegex(str(warn[0].message),
+ '.*relying on deprecated non-standard defaults.*'
+ 'explicitly use: b=2, c=3')
diff --git a/tests/test_gio.py b/tests/test_gio.py
index 3b812c4..07ee506 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -50,8 +50,8 @@ class TestGio(unittest.TestCase):
Gio.VolumeMonitor()
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*Gio\\.VolumeMonitor\\.get\\(\\).*')
+ self.assertRegex(str(warn[0].message),
+ '.*Gio\\.VolumeMonitor\\.get\\(\\).*')
class TestGSettings(unittest.TestCase):
diff --git a/tests/test_overrides_gdk.py b/tests/test_overrides_gdk.py
index 1788ef6..d959571 100644
--- a/tests/test_overrides_gdk.py
+++ b/tests/test_overrides_gdk.py
@@ -227,8 +227,8 @@ class TestGdk(unittest.TestCase):
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*new_from_pixbuf.*')
+ self.assertRegex(str(warn[0].message),
+ '.*new_from_pixbuf.*')
self.assertRaises(ValueError, Gdk.Cursor, 1, 2, 3)
diff --git a/tests/test_overrides_glib.py b/tests/test_overrides_glib.py
index d8f1a6c..08c41ae 100644
--- a/tests/test_overrides_glib.py
+++ b/tests/test_overrides_glib.py
@@ -691,30 +691,30 @@ class TestGVariant(unittest.TestCase):
def test_parse_error_exceptions(self):
source_str = 'abc'
- self.assertRaisesRegexp(TypeError, 'Must be GLib.Error, not int',
- GLib.Variant.parse_error_print_context,
- 42, source_str)
+ self.assertRaisesRegex(TypeError, 'Must be GLib.Error, not int',
+ GLib.Variant.parse_error_print_context,
+ 42, source_str)
gerror = GLib.Error(message=42) # not a string
- self.assertRaisesRegexp(TypeError, ".*Must be string, not int.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(TypeError, ".*Must be string, not int.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
gerror = GLib.Error(domain=42) # not a string
- self.assertRaisesRegexp(TypeError, ".*Must be string, not int.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(TypeError, ".*Must be string, not int.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
gerror = GLib.Error(code='not an int')
- self.assertRaisesRegexp(TypeError, ".*Must be number, not str.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(TypeError, ".*Must be number, not str.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
gerror = GLib.Error(code=GLib.MAXUINT)
- self.assertRaisesRegexp(OverflowError,
- ".*not in range.*",
- GLib.Variant.parse_error_print_context,
- gerror, source_str)
+ self.assertRaisesRegex(OverflowError,
+ ".*not in range.*",
+ GLib.Variant.parse_error_print_context,
+ gerror, source_str)
class TestConstants(unittest.TestCase):
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 30ad1d8..091a6a2 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -403,8 +403,8 @@ class TestGtk(unittest.TestCase):
self.assertTrue(dialog.get_modal())
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGTKDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*flags.*modal.*')
+ self.assertRegex(str(warn[0].message),
+ '.*flags.*modal.*')
with warnings.catch_warnings(record=True) as warn:
warnings.simplefilter('always')
@@ -412,8 +412,8 @@ class TestGtk(unittest.TestCase):
self.assertTrue(dialog.get_destroy_with_parent())
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGTKDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*flags.*destroy_with_parent.*')
+ self.assertRegex(str(warn[0].message),
+ '.*flags.*destroy_with_parent.*')
def test_dialog_deprecation_stacklevels(self):
# Test warning levels are setup to give the correct filename for
@@ -425,7 +425,7 @@ class TestGtk(unittest.TestCase):
warnings.simplefilter('always')
Gtk.Dialog(flags=Gtk.DialogFlags.MODAL)
self.assertEqual(len(warn), 1)
- self.assertRegexpMatches(warn[0].filename, '.*test_overrides_gtk.*')
+ self.assertRegex(warn[0].filename, '.*test_overrides_gtk.*')
# Validate overridden base with overridden sub-class.
self.assertEqual(Gtk.MessageDialog, gi.overrides.Gtk.MessageDialog)
@@ -433,7 +433,7 @@ class TestGtk(unittest.TestCase):
warnings.simplefilter('always')
Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL)
self.assertEqual(len(warn), 1)
- self.assertRegexpMatches(warn[0].filename, '.*test_overrides_gtk.*')
+ self.assertRegex(warn[0].filename, '.*test_overrides_gtk.*')
# Validate overridden base with non-overridden sub-class.
self.assertEqual(Gtk.AboutDialog, gi.repository.Gtk.AboutDialog)
@@ -441,7 +441,7 @@ class TestGtk(unittest.TestCase):
warnings.simplefilter('always')
Gtk.AboutDialog(flags=Gtk.DialogFlags.MODAL)
self.assertEqual(len(warn), 1)
- self.assertRegexpMatches(warn[0].filename, '.*test_overrides_gtk.*')
+ self.assertRegex(warn[0].filename, '.*test_overrides_gtk.*')
def test_dialog_add_buttons(self):
# The overloaded "buttons" keyword gives a warning when attempting
@@ -452,8 +452,8 @@ class TestGtk(unittest.TestCase):
buttons=('test-button1', 1))
self.assertEqual(len(warn), 1)
self.assertTrue(issubclass(warn[0].category, PyGTKDeprecationWarning))
- self.assertRegexpMatches(str(warn[0].message),
- '.*ButtonsType.*add_buttons.*')
+ self.assertRegex(str(warn[0].message),
+ '.*ButtonsType.*add_buttons.*')
dialog.add_buttons('test-button2', 2, 'gtk-close', Gtk.ResponseType.CLOSE)
button = dialog.get_widget_for_response(1)
--
1.8.3.1

View File

@ -0,0 +1,29 @@
From 6c17628365abfcd7d5868f6f812390380c0ad1ec Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Tue, 30 Mar 2021 08:04:47 +0200
Subject: [PATCH] tests: fix test with glib 2.68 re GLocalFile
Since 2.68 Gio.File.new_for_path("") returns a GDummyFile instead of
a GLocalFile. We don't really care since we just want to test that there
is a name despite the type not being in the gir, so just pass a potentially
valid path instead.
---
tests/test_gi.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 5e7d0e3..f655266 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2406,7 +2406,7 @@ class TestGObject(unittest.TestCase):
def test_nongir_repr(self):
self.assertRegex(
- repr(Gio.File.new_for_path("")),
+ repr(Gio.File.new_for_path("/")),
r"<__gi__.GLocalFile object at 0x[^\s]+ "
r"\(GLocalFile at 0x[^\s]+\)>")
--
1.8.3.1

View File

@ -0,0 +1,28 @@
From 6033ab41cdf3ec8d7e689e2a3ea832ed5dfdcf8b Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Sun, 15 Nov 2020 13:32:30 +0100
Subject: [PATCH] tests: fix tests with glib master
GFileIcon asserts that it gets a file now:
https://gitlab.gnome.org/GNOME/glib/-/commit/e2fbb74301
---
tests/test_gobject.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index 77d788a..f5a65bb 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -833,7 +833,8 @@ def test_list_properties():
assert list_props("GFileIcon") == list_props(Gio.FileIcon)
assert list_props(Gio.FileIcon.__gtype__) == list_props(Gio.FileIcon)
- assert list_props(Gio.FileIcon()) == list_props(Gio.FileIcon)
+ assert list_props(Gio.FileIcon(
+ file=Gio.File.new_for_path('.'))) == list_props(Gio.FileIcon)
for obj in [Gio.ActionEntry, Gio.DBusError, 0, object()]:
with pytest.raises(TypeError):
--
1.8.3.1