# Date 1736546216 18000
# Fri Jan 10 16:56:56 2025 -0500
# Branch stable
# Node ID 43c4af2c5f542a8a9e547c0b735ce26b91af03b2
# Parent b143524983fec3327019557a5e336e96c015fcf3
# EXP-Topic windows-test-fixes
tests: skip QTextCodec dependent tests with Qt6 (fixes #6010)
This class was removed in Qt6, and it's not obvious how to replace the
functionality that went missing. If someone cares, they can resurrect this.
diff --git a/tests/helpers.py b/tests/helpers.py
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -8,9 +8,14 @@
import time
from collections import defaultdict
-from tortoisehg.hgqt.qtcore import (
- QTextCodec,
-)
+try:
+ from tortoisehg.hgqt.qtcore import (
+ QTextCodec,
+ )
+except ImportError:
+ # QStringConverter is supposed to be the replacement on Qt6, but is missing
+ # a lot of stuff.
+ QTextCodec = None
from mercurial import (
dispatch,
diff --git a/tests/hglib_encoding_test.py b/tests/hglib_encoding_test.py
--- a/tests/hglib_encoding_test.py
+++ b/tests/hglib_encoding_test.py
@@ -8,6 +8,7 @@
JAPANESE_KANA_I = u'\u30a4' # Japanese katakana "i"
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('utf-8')
def test_none():
"""None shouldn't be touched"""
@@ -16,59 +17,71 @@
assert f(None) is None
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('utf-8')
def test_fromunicode():
assert hglib.fromunicode(JAPANESE_KANA_I) == JAPANESE_KANA_I.encode('utf-8')
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii', 'utf-8')
def test_fromunicode_fallback():
assert hglib.fromunicode(JAPANESE_KANA_I) == JAPANESE_KANA_I.encode('utf-8')
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii')
def test_fromunicode_replace():
assert hglib.fromunicode(JAPANESE_KANA_I, errors='replace') == b'?'
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii')
def test_fromunicode_strict():
with pytest.raises(UnicodeEncodeError):
hglib.fromunicode(JAPANESE_KANA_I)
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('euc-jp')
def test_fromutf():
assert (hglib.fromutf(JAPANESE_KANA_I.encode('utf-8'))
== JAPANESE_KANA_I.encode('euc-jp'))
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii', 'euc-jp')
def test_fromutf_fallback():
assert (hglib.fromutf(JAPANESE_KANA_I.encode('utf-8'))
== JAPANESE_KANA_I.encode('euc-jp'))
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii')
def test_fromutf_replace():
assert hglib.fromutf(JAPANESE_KANA_I.encode('utf-8')) == b'?'
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('euc-jp')
def test_tounicode():
assert hglib.tounicode(JAPANESE_KANA_I.encode('euc-jp')) == JAPANESE_KANA_I
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii', 'euc-jp')
def test_tounicode_fallback():
assert hglib.tounicode(JAPANESE_KANA_I.encode('euc-jp')) == JAPANESE_KANA_I
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('euc-jp')
def test_toutf():
assert (hglib.toutf(JAPANESE_KANA_I.encode('euc-jp'))
== JAPANESE_KANA_I.encode('utf-8'))
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii', 'euc-jp')
def test_toutf_fallback():
assert (hglib.toutf(JAPANESE_KANA_I.encode('euc-jp'))
== JAPANESE_KANA_I.encode('utf-8'))
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('gbk')
def test_gbk_roundtrip():
# gbk byte sequence can also be interpreted as utf-8 (issue #3299)
@@ -77,12 +90,14 @@
assert hglib.tounicode(l) == MOKU
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii')
def test_lossless_unicode_replaced():
l = hglib.fromunicode(JAPANESE_KANA_I, 'replace')
assert l == b'?'
assert hglib.tounicode(l) == JAPANESE_KANA_I
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('euc-jp')
def test_lossless_unicode_double_mapped():
YEN = u'\u00a5' # "yen" and "back-slash" are mapped to the same code
@@ -90,6 +105,7 @@
assert l == b'\\'
assert hglib.tounicode(l) == YEN
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii')
def test_lossless_utf_replaced():
u = JAPANESE_KANA_I.encode('utf-8')
@@ -97,6 +113,7 @@
assert l == b'?'
assert hglib.toutf(l) == u
+...@pytest.mark.skipif(helpers.QTextCodec is None, reason="Qt6 not supported")
@helpers.with_encoding('ascii')
def test_lossless_utf_cannot_roundtrip():
u = JAPANESE_KANA_I.encode('cp932') # bad encoding
diff --git a/tests/qt_manifestmodel_test.py b/tests/qt_manifestmodel_test.py
--- a/tests/qt_manifestmodel_test.py
+++ b/tests/qt_manifestmodel_test.py
@@ -685,6 +685,10 @@
# TODO: make this compatible with binary-unsafe filesystem
if
os.name != 'posix' or sys.platform == 'darwin':
raise unittest.SkipTest
+ # TODO: figure out the replacement for QTextCodec on Qt6
+ if helpers.QTextCodec is None:
+ raise unittest.SkipTest
+