Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#8183 closed defect (fixed)

tracspamfilter breaks trac tests

Reported by: Shane Caraveo <shanec@…> Owned by: Tim Hatch
Priority: normal Milestone: 0.11.5
Component: general Version: 0.11.4
Severity: normal Keywords: doctest
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Tim Hatch)

I realize this is a plugin, but the fix is in trac/test.py. If tracspamfilter is installed, unittests break left and right. I haven't been able to trac down the exact reason, but commenting out the doctests fixes the issue.

One example traceback:

======================================================================
ERROR: test_version_time_unset_ok (trac.admin.tests.console.TracadminTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/shanec/svn/workspace/trunk/build/vendor/trac/trac/admin/tests/console.py", line 99, in setUp
    self.env = InMemoryEnvironment('', create=True)
  File "/Users/shanec/svn/workspace/trunk/build/vendor/trac/trac/env.py", line 212, in __init__
    load_components(self, plugins_dir and (plugins_dir,))
  File "/Users/shanec/svn/workspace/trunk/build/vendor/trac/trac/loader.py", line 111, in load_components
    loadfunc(env, search_path, auto_enable=plugins_dir)
  File "/Users/shanec/svn/workspace/trunk/build/vendor/trac/trac/loader.py", line 68, in _load_eggs
    entry.load(require=True)
  File "/Users/shanec/svn/workspace/trunk/new/trac/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 1913, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Users/shanec/svn/workspace/trunk/build/plugins/spam-filter/tracspamfilter/filters/bayes.py", line 30, in <module>
    from spambayes.hammie import Hammie
  File "/Users/shanec/svn/workspace/trunk/new/trac/lib/python2.5/site-packages/spambayes-1.1a4-py2.5.egg/spambayes/hammie.py", line 5, in <module>
    from spambayes import storage
  File "/Users/shanec/svn/workspace/trunk/new/trac/lib/python2.5/site-packages/spambayes-1.1a4-py2.5.egg/spambayes/storage.py", line 70, in <module>
    from spambayes import classifier
  File "/Users/shanec/svn/workspace/trunk/new/trac/lib/python2.5/site-packages/spambayes-1.1a4-py2.5.egg/spambayes/classifier.py", line 79, in <module>
    from spambayes.Options import options
  File "/Users/shanec/svn/workspace/trunk/new/trac/lib/python2.5/site-packages/spambayes-1.1a4-py2.5.egg/spambayes/Options.py", line 68, in <module>
    ("basic_header_tokenize", _("Basic header tokenising"), False,
TypeError: 'str' object is not callable

If you look at Options.py, there is a try block around "_" near the top of the file. It seems that when doctests are run, _ gets set to the expected output of a doctest (a string, int, whatever). That passes the try block in Options.py, but causes failure later.

I have a patch to test.py that still runs doctests, and avoids this problem.

Attachments (1)

trac-doctest-8183.patch (771 bytes ) - added by Shane Caraveo <shanec@…> 16 years ago.

Download all attachments as: .zip

Change History (3)

by Shane Caraveo <shanec@…>, 16 years ago

Attachment: trac-doctest-8183.patch added

comment:1 by Tim Hatch, 16 years ago

Description: modified (diff)
Milestone: 0.11.5
Resolution: fixed
Status: newclosed
Version: none0.11.4

I confirm the issue with rework-testing branch + easy_install tracspamfilter spambayes on my system. The only way _ could be getting into newly-imported modules is if it's part of builtins, so there's a fix in r8023 that removes it. This solves it on my system.

comment:2 by Christian Boos, 16 years ago

Keywords: doctest added
Owner: set to Tim Hatch

He, yet another good reason for justifying why we didn't use _ as a builtin ourselves.

Tim, I assume you target the 0.11.5 branch for the sandbox testing-rework. If not, then please retarget this ticket to the 0.12 milestone (usually we only close tickets when the fix lands on trunk or on a stable branch, but no big deal).

Modify Ticket

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