Edgewall Software
Modify

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#12822 closed defect (fixed)

TestTicketHistory randomly fails

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.3.2
Component: ticket system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Use url-regexp for tc.follow() rather than text-regexp to avoid modifying incorrect textarea value by twill.

API Changes:

Description

attachment:TestTicketHistory.html

FAIL: runTest (trac.ticket.tests.functional.main.TestTicketHistory)
Test ticket history
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/run/shm/42f422aebc5dc41d5fb7fe0ebf137c461b3790f3/py27-sqlite/trac/ticket/tests/functional/main.py", line 333, in runTest
    tc.url(url + re.escape(r'?action=comment-diff&cnum=1&version=1'))
  File "/run/shm/42f422aebc5dc41d5fb7fe0ebf137c461b3790f3/py27-sqlite/trac/tests/functional/better_twill.py", line 243, in better_url
    (to_unicode(e), filename))
TwillAssertionError: current url is 'http://127.0.0.1:8594/ticket/35?action=diff&version=1';
does not match 'http://127.0.0.1:8594/ticket/35\?action\=comment\-diff\&cnum\=1\&version\=1'
 at file:///run/shm/42f422aebc5dc41d5fb7fe0ebf137c461b3790f3/py27-sqlite/testenv/trac/log/TestTicketHistory.html

Attachments (1)

TestTicketHistory.html (10.6 KB ) - added by Jun Omae 2 years ago.

Download all attachments as: .zip

Change History (6)

by Jun Omae, 2 years ago

Attachment: TestTicketHistory.html added

comment:1 by Jun Omae, 2 years ago

The ticket's description is rarely modified by adding The original comment at trunk/trac/ticket/tests/functional/main.py@15930:281#L276 (~1%). This behavior leads another diff link for the description. As the result, tc.follow(r"\bdiff\b") follows incorrect link.

I guess that is a twill issue.

Work around is to make the description field empty.

  • trac/ticket/tests/functional/main.py

    diff --git a/trac/ticket/tests/functional/main.py b/trac/ticket/tests/functional/main.py
    index 039c1e9eb..727c31eb8 100755
    a b class TestTicketHistory(FunctionalTwillTestCaseSetup):  
    277277    def runTest(self):
    278278        """Test ticket history"""
    279279        summary = random_sentence(5)
    280         ticketid = self._tester.create_ticket(summary)
     280        ticketid = self._tester.create_ticket(summary, {'description': ''})
    281281        comment = self._tester.add_comment(ticketid, "The original comment")
    282282        self._tester.go_to_ticket(ticketid)
    283283        tc.find(r'<a [^>]+>\bModify\b</a>')

comment:2 by Ryan J Ollos, 2 years ago

Good find! I have been trying to sort this one out for a while.

comment:3 by Jun Omae, 2 years ago

Milestone: next-dev-1.3.x1.3.2

Another fix, we could use url-regexp rather than text-regexp. tc.follow() accepts url-regexp.

  • trac/ticket/tests/functional/main.py

    commit a44eea31da7bb879f4fba878e13e38c8fc292c7d
    Author: Jun Omae <jun66j5@gmail.com>
    Date:   Sun May 28 00:24:13 2017 +0900
    
        (#12821) use url-regexp for `tc.follow()` rather than text-regexp to avoid following incorrect diff link
    
    diff --git a/trac/ticket/tests/functional/main.py b/trac/ticket/tests/functional/main.py
    index 039c1e9eb..04b94d044 100755
    a b class TestTicketHistory(FunctionalTwillTestCaseSetup):  
    327327        tc.url(url + re.escape(r'?cversion=1&cnum_hist=1#comment:1'))
    328328
    329329        # View comment diff.
    330         tc.follow(r"\bdiff\b")
     330        tc.follow(r'^/ticket/%s\?action=comment-diff&cnum=1&version=1$' %
     331                  ticketid)
    331332        tc.notfind(r"\bComment:\b")
    332333        tc.find(r"\bChanges between\b")
    333334        tc.url(url + re.escape(r'?action=comment-diff&cnum=1&version=1'))

comment:4 by Jun Omae, 2 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Changes in comment:3 has been applied in [15963].

comment:5 by Jun Omae, 2 years ago

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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