From 63245dc6083483cc62752589e8dbd8bea4222eca Mon Sep 17 00:00:00 2001 From: jomae Date: Mon, 30 Sep 2024 02:57:21 +0000 Subject: [PATCH] 1.6.1dev: fix functional tests failing when tidylib is loaded from /usr/lib on macOS git-svn-id: http://trac.edgewall.org/intertrac/log:/branches/1.6-stable@17845 af82e41b-90c4-0310-8c96-b1721e28e2e2 --- contrib/make_status.py | 20 +++++++++++++------- trac/tests/functional/better_twill.py | 18 +++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/contrib/make_status.py b/contrib/make_status.py index 2e23cf8324..31ab602782 100755 --- a/contrib/make_status.py +++ b/contrib/make_status.py @@ -30,13 +30,19 @@ def _pytidylib_version(): info = 'not installed' else: import ctypes - cdll = tidy._tidy - fn = cdll.tidyLibraryVersion - fn.restype = ctypes.c_char_p - libver = fn() - if isinstance(libver, bytes): - libver = str(libver, 'utf-8') - info = '%s %s' % (libver, cdll._name) + try: + cdll = tidy._tidy + try: + fn = cdll.tidyLibraryVersion + fn.restype = ctypes.c_char_p + libver = fn() + if isinstance(libver, bytes): + libver = str(libver, 'utf-8') + except Exception as e: + libver = repr(e) + info = '%s %s' % (libver, cdll._name) + except Exception as e: + info = repr(e) return '%s (%s)' % (version, info) if info else version def _pysqlite3_version(): diff --git a/trac/tests/functional/better_twill.py b/trac/tests/functional/better_twill.py index 8d1a58e8ac..aee512b495 100755 --- a/trac/tests/functional/better_twill.py +++ b/trac/tests/functional/better_twill.py @@ -40,10 +40,16 @@ except ImportError: selenium = None + +_tidy_options = { + 'escape-scripts': 0, + 'drop-empty-elements': 0, +} _curr = locale.setlocale(locale.LC_ALL, None) try: import tidylib - tidylib.tidy_document('') + tidylib.tidy_document('', + _tidy_options) except ImportError: print("SKIP: validation of HTML output in functional tests" " (no tidylib installed)") @@ -52,6 +58,9 @@ print("SKIP: validation of HTML output in functional tests" " (no tidy dynamic library installed: %s)" % e) tidy_document = None +except ValueError as e: + print("SKIP: validation of HTML output in functional tests (%r)" % e) + tidy_document = None else: if _curr == locale.setlocale(locale.LC_ALL, None): tidy_document = tidylib.tidy_document @@ -562,11 +571,6 @@ def _urljoin(self, url): url = urljoin(self.get_url(), url) return url - _tidy_options = { - 'escape-scripts': 0, - 'drop-empty-elements': 0, - } - _doctype_re = re.compile(r'\s*