Edgewall Software
Modify

Opened 10 years ago

Closed 10 years ago

#11635 closed enhancement (fixed)

BetterTwill: Output path to HTML file as followable link

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.2
Component: general Version:
Severity: normal Keywords: twill functional tests
Cc: Branch:
Release Notes:

When an HTML page is created due to an exception in the functional test suite, the URL of the file is used in the exception message so the terminal can create a clickable link.

API Changes:
Internal Changes:

Description

When a twill test fails, we get output such as the following:

======================================================================
FAIL: runTest (__main__.TestDefaultHandler)
Set default handler from the Basic Settings page.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "trac/admin/tests/functional.py", line 133, in runTest
    tc.find(r'<option value="BatchModifyModule">BatchModifyModule'
  File "/home/user/Workspace/tracdev/teo-rjollos.git/trac/tests/functional/better_twill.py", line 225, in better_find
    raise twill.errors.TwillAssertionError(*args)
TwillAssertionError: ('no match to \'<option value="BatchModifyModule">BatchModifyModule</option>\'', '/home/user/Workspace/tracdev/teo-rjollos.git/testenv/trac/log/TestDefaultHandler.html')

I've wondered whether /home/user/Workspace/tracdev/teo-rjollos.git/testenv/trac/log/TestDefaultHandler.html can be rendered in the terminal as a followable link for all OSs that we support, or at least for the most widely used ones (sh and Windows Command Prompt, at least).

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 10 years ago

I typically use Gnome Terminal. The feature I wish to take advantage of is URL detection. This could be accomplished with a change such as the following:

  • trac/tests/functional/better_twill.py

    diff --git a/trac/tests/functional/better_twill.py b/trac/tests/functional/better_twill.py
    index 9f9281b..1be577a 100755
    a b It also handles twill's absense.  
    1717"""
    1818
    1919import os
    20 from os.path import abspath, dirname, join
    2120import sys
     21import urllib
     22import urlparse
     23from os.path import abspath, dirname, join
    2224from pkg_resources import parse_version as pv
    2325try:
    2426    from cStringIO import StringIO
    if twill:  
    160162        html_file.write(b.get_html())
    161163        html_file.close()
    162164
    163         return filename
     165        return urlparse.urljoin('file:', urllib.pathname2url(filename))
    164166
    165167    # Twill isn't as helpful with errors as I'd like it to be, so we replace
    166168    # the formvalue function.  This would be better done as a patch to Twill.

The output would be:

TwillAssertionError: ("no match to 'Your changes have been saved.!!'", 'file:///home/user/Workspace/tracdev/teo-rjollos.git/testenv/trac/log/TestDefaultHandler.html')

rather than:

TwillAssertionError: ("no match to 'Your changes have been saved.!!'", '/home/user/Workspace/tracdev/teo-rjollos.git/testenv/trac/log/TestDefaultHandler.html')

and a CTRL+click while hovering over the file URL opens the file in the default web browser.

However, I've not evaluated the cross-platform or cross-terminal usability of the change.

comment:2 by Jun Omae, 10 years ago

I don't use URL detection (I'm using PuTTY on Windows), but that's okay. Because Vim can open the file:/// resource. Also, I tried with ConEmu. The terminal detects file:///....html') as a link.

I think the detection and message would be good to apply the following.

  • trac/tests/functional/better_twill.py

    a b if twill:  
    221223            tcfind(what, flags)
    222224        except twill.errors.TwillAssertionError as e:
    223225            filename = twill_write_html()
    224             args = e.args + (filename,)
    225             raise twill.errors.TwillAssertionError(*args)
     226            raise twill.errors.TwillAssertionError('%s at %s' %
     227                                                   (unicode(e), filename))
Traceback (most recent call last):
  File "trac\admin\tests\functional.py", line 73, in runTest
    tc.find('https://my.example.com/something')
  File "C:\usr\src\trac\trac.git\trac\tests\functional\better_twill.py", line 227, in better_find
    (unicode(e), filename))
TwillAssertionError: no match to 'https://my.example.com/something' at file:///C:/usr/src/trac/trac.git/testenv/trac/log/TestBasicSettings.html

The link can open the html file on Firefox by clicking.

comment:3 by Ryan J Ollos, 10 years ago

Milestone: 1.0.2
Owner: set to Ryan J Ollos
Status: newassigned

comment:4 by Ryan J Ollos, 10 years ago

Do the changes in log:rjollos.git:t11635 look good?

comment:5 by Jun Omae, 10 years ago

I tried the branch with conemu. It looks good to me.

comment:6 by Ryan J Ollos, 10 years ago

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

Committed to 1.0-stable in [12880], merged to trunk in [12881]. Tested on my end with Ubuntu 13.04.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos 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.