Edgewall Software

Opened 3 months ago

Closed 3 months ago

#13577 closed defect (fixed)

FAIL: test_pretty_dateinfo without Babel on windows-2022 image

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.6
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Fixed test failing due to locale.setlocale().



FAIL: test_pretty_dateinfo (trac.web.tests.chrome.ChromeTemplateRenderingTestCase)
Traceback (most recent call last):
  File "D:\a\trac\trac\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">[0-9]+ years ago</span></li>\n<li><span title="07/01/(20)?07 12:34:56">[0-9]+ years ago</span></li>\n<li><span title="[0-9]+ years ago">on 07/01/(20)?07</span></li>\n<li><span title="[0-9]+ years ago">on 07/01/(20)?07 at 12:34:56</span></li>\n<li><span title="[0-9]+ years ago">07/01/(20)?07</span></li>\n<li><span title="[0-9]+ 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="7/1/2007 12:34:56 PM">16 years ago</span></li>\n<li><span title="7/1/2007 12:34:56 PM">16 years ago</span></li>\n<li><span title="16 years ago">on 7/1/2007</span></li>\n<li><span title="16 years ago">on 7/1/2007 at 12:34:56 PM</span></li>\n<li><span title="16 years ago">7/1/2007</span></li>\n<li><span title="16 years ago">7/1/2007 12:34:56 PM</span></li>\n</ul>\n</body>\n</html>' : <!DOCTYPE html>
<li><span title="7/1/2007 12:34:56 PM">16 years ago</span></li>
<li><span title="7/1/2007 12:34:56 PM">16 years ago</span></li>
<li><span title="16 years ago">on 7/1/2007</span></li>
<li><span title="16 years ago">on 7/1/2007 at 12:34:56 PM</span></li>
<li><span title="16 years ago">7/1/2007</span></li>
<li><span title="16 years ago">7/1/2007 12:34:56 PM</span></li>

Ran 2472 tests in 234.103s

FAILED (failures=1, skipped=9)
mingw32-make: *** [makefile:477: unit-test] Error 1

We expects 07/01/2007 12:34:56 PM but got 7/1/2007 12:34:56 PM. It seems that date formats are changed in the user session on windows-2022 image….

Attachments (0)

Change History (2)

comment:1 by Jun Omae, 3 months ago

Owner: set to Jun Omae
Status: newassigned

Ah, that's my fault. The root cause is that locale.setlocale() is invoked from dispatch_request after r17686.

After confirming unit tests pass on CI, I'll push the following changes:

  • trac/web/tests/cgi_frontend.py

    diff --git a/trac/web/tests/cgi_frontend.py b/trac/web/tests/cgi_frontend.py
    index cd47452e6..e01dffd00 100644
    a b import unittest  
    1818from trac.test import makeSuite, mkdtemp, rmtree
    1919from trac.web.cgi_frontend import CGIGateway
    20 from trac.web.main import dispatch_request
     20from trac.web.main import send_project_index
    2323class CGIRequestTestCase(unittest.TestCase):
    class CGIRequestTestCase(unittest.TestCase):  
    3939        rmtree(self.tmpdir)
    4141    def test_write_project_index(self):
     43        # XXX invoke directly send_project_index() to avoid call of
     44        #     locale.setlocale() from dispatch_request
     45        def dispatch_request(environ, start_response):
     46            send_project_index(environ, start_response)
     47            return []
    4249        gateway = CGIGateway()
    4350        gateway.environ.update({
    4451            'trac.env_parent_dir': self.tmpdir,

comment:2 by Jun Omae, 3 months ago

Internal Changes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [17687].

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.