Opened 4 years ago
Closed 4 years ago
#13361 closed defect (fixed)
test_pretty_dateinfo failing when Babel is unavailable
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.3 |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Workaround for test failures due to changing locale on call of |
||
API Changes: | |||
Internal Changes: |
Description
I noticed the following test fails while working tests with build=minimum
on GitHub Actions.
====================================================================== FAIL: test_pretty_dateinfo (trac.web.tests.chrome.ChromeTemplateRenderingTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/jun66j5/src/tracdev/git/trac/web/tests/chrome.py", line 1118, in test_pretty_dateinfo self.assertRegex(content, textwrap.dedent("""\ AssertionError: Regex didn't match: '<!DOCTYPE html>\n<html>\n<body>\n<ul>\n<li></li>\n<li><span title="07/01/(20)?07 12:34:56">\\d+ years ago</span></li>\n<li><span title="07/01/(20)?07 12:34:56">\\d+ years ago</span></li>\n<li><span title="\\d+ years ago">on 07/01/(20)?07</span></li>\n<li><span title="\\d+ years ago">on 07/01/(20)?07 at 12:34:56</span></li>\n<li><span title="\\d+ years ago">07/01/(20)?07</span></li>\n<li><span title="\\d+ years ago">07/01/(20)?07 12:34:56</span></li>\n</ul>\n</body>\n</html>' not found in '<!DOCTYPE html>\n<html>\n<body>\n<ul>\n<li></li>\n<li><span title="07/01/2007 12:34:56 PM">14 years ago</span></li>\n<li><span title="07/01/2007 12:34:56 PM">14 years ago</span></li>\n<li><span title="14 years ago">on 07/01/2007</span></li>\n<li><span title="14 years ago">on 07/01/2007 at 12:34:56 PM</span></li>\n<li><span title="14 years ago">07/01/2007</span></li>\n<li><span title="14 years ago">07/01/2007 12:34:56 PM</span></li>\n</ul>\n</body>\n</html>' : <!DOCTYPE html> <html> <body> <ul> <li></li> <li><span title="07/01/2007 12:34:56 PM">14 years ago</span></li> <li><span title="07/01/2007 12:34:56 PM">14 years ago</span></li> <li><span title="14 years ago">on 07/01/2007</span></li> <li><span title="14 years ago">on 07/01/2007 at 12:34:56 PM</span></li> <li><span title="14 years ago">07/01/2007</span></li> <li><span title="14 years ago">07/01/2007 12:34:56 PM</span></li> </ul> </body> </html>
Work around is to add export LANC=C
before make unit-test
but the issue is not fixed on Windows. setlocale()
in C runtime on Windows doesn't respect LANG
, LC_*
environments.
Attachments (0)
Change History (5)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Component: | i18n → general |
---|---|
Owner: | set to |
Status: | new → assigned |
Proposed changes restore the locale after call of tidylib.tidy_document
.
-
trac/tests/functional/better_twill.py
diff --git a/trac/tests/functional/better_twill.py b/trac/tests/functional/better_twill.py index eeb9fdb21..adbf25faa 100755
a b It also handles twill's absense. 19 19 import hashlib 20 20 import http.client 21 21 import http.server 22 import locale 22 23 import re 23 24 import os.path 24 25 import socketserver … … try: 36 37 except ImportError: 37 38 selenium = None 38 39 40 _curr = locale.setlocale(locale.LC_ALL, None) 39 41 try: 40 from tidylib import tidy_document41 tidy _document('<!DOCTYPE html><html><body></body></html>')42 import tidylib 43 tidylib.tidy_document('<!DOCTYPE html><html><body></body></html>') 42 44 except ImportError: 43 45 print("SKIP: validation of HTML output in functional tests" 44 46 " (no tidylib installed)") … … except OSError as e: 47 49 print("SKIP: validation of HTML output in functional tests" 48 50 " (no tidy dynamic library installed: %s)" % e) 49 51 tidy_document = None 52 else: 53 if _curr == locale.setlocale(locale.LC_ALL, None): 54 tidy_document = tidylib.tidy_document 55 else: 56 def tidy_document(*args, **kwargs): 57 curr = locale.setlocale(locale.LC_ALL, None) 58 try: 59 return tidylib.tidy_document(*args, **kwargs) 60 finally: 61 # Restore the locale because tidy-html5 library changes the 62 # locale each call of tidy_document if 5.6.0 or early. 63 locale.setlocale(locale.LC_ALL, curr) 64 finally: 65 if _curr != locale.setlocale(locale.LC_ALL, None): 66 locale.setlocale(locale.LC_ALL, _curr) 67 del _curr 50 68
comment:3 by , 4 years ago
Proposed changes in log:jomae.git@trunk:t13361.
In addition, I think it would be good to show version and name of libtidy shared library.
$ make python=39 status ... Docutils : 0.16 Selenium : 3.141.0 PyTidyLib : 0.3.2 (5.6.0 libtidy.so.5deb1) LXML : 4.6.2 coverage : 5.5 ...
comment:5 by , 4 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Thanks for the reviewing. Committed in [17517:17518].
I found the
setlocale()
is invoked by each call oftidylib.tidy_document
.refs. https://github.com/htacg/tidy-html5/blob/5.6.0/src/tidylib.c#L122
Also, in tidy-html5 5.7.28, calls of
setlocale()
have been removed.