[pygobject] tests: fix glib tests with newest glib
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] tests: fix glib tests with newest glib
- Date: Fri, 16 Mar 2018 23:05:35 +0000 (UTC)
commit 550bd7c7c2b838bc46dafb92dad222d90bb19cda
Author: Christoph Reiter <reiter christoph gmail com>
Date: Fri Mar 16 23:48:20 2018 +0100
tests: fix glib tests with newest glib
g_filename_from_utf8() was recently fixed to return filenames
instead of bytes.
See https://bugzilla.gnome.org/show_bug.cgi?id=756128
tests/test_glib.py | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/tests/test_glib.py b/tests/test_glib.py
index 8f481947..5b64466c 100644
--- a/tests/test_glib.py
+++ b/tests/test_glib.py
@@ -14,6 +14,8 @@ import pytest
from gi.repository import GLib
from gi import PyGIDeprecationWarning
+from .compathelper import PY3
+
class TestGLib(unittest.TestCase):
@@ -76,13 +78,30 @@ class TestGLib(unittest.TestCase):
self.assertEqual(GLib.filename_display_name('foo'), 'foo')
self.assertEqual(GLib.filename_display_basename('bar/foo'), 'foo')
+ def glibfsencode(f):
+ # the annotations of filename_from_utf8() was changed in
+ # https://bugzilla.gnome.org/show_bug.cgi?id=756128
+ if isinstance(f, bytes):
+ return f
+ if os.name == "nt":
+ if PY3:
+ return f.encode("utf-8", "surrogatepass")
+ else:
+ return f.encode("utf-8")
+ else:
+ assert PY3
+ return os.fsencode(f)
+
# this is locale dependent, so we cannot completely verify the result
res = GLib.filename_from_utf8(u'aäb')
+ res = glibfsencode(res)
self.assertTrue(isinstance(res, bytes))
self.assertGreaterEqual(len(res), 3)
# with explicit length argument
- self.assertEqual(GLib.filename_from_utf8(u'aäb', 1), b'a')
+ res = GLib.filename_from_utf8(u'aäb', 1)
+ res = glibfsencode(res)
+ self.assertEqual(res, b'a')
def test_uri_extract(self):
res = GLib.uri_list_extract_uris('''# some comment
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]