Edgewall Software

Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#11316 closed defect (fixed)

Test failures in trac.wiki.tests.formatter when executed in isolation — at Version 2

Reported by: Ryan J Ollos Owned by:
Priority: normal Milestone: 1.0.5
Component: wiki system Version:
Severity: normal Keywords: unit tests
Cc: Branch:
Release Notes:

Modified Make file to run python setup.py -q test -s <pkg.module.suite>, which avoids test failures when running tests in a module.

API Changes:
Internal Changes:

Description

Executing all of the tests in trac.wiki.tests succeeds,

PYTHONPATH=. python -m trac.wiki.tests.__init__
...................................................................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 355 tests in 1.417s

OK

However, executing just the tests in trac.wiki.tests.formatter fails:

PYTHONPATH=. python -m trac.wiki.tests.formatter
...........................................................................................F.F........................................................................................................................................................
======================================================================
FAIL: test (__main__.WikiTestCase)
Test Macro help shortcut (with content)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/Workspace/t10834/teo-rjollos.git/trac/wiki/tests/formatter.py", line 222, in test
    % (msg, self.file, self.line, self.title, formatter.flavor))
AssertionError: 
========== expected: ==========
<p>
</p><div class="trac-macrolist"><h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
A dummy macro used by the unit test.
</p>
</div><p>
</p>


========== actual: ==========
<p>
</p><div class="trac-macrolist"><h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
A dummy macro used by the unit test.
</p>
<h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
A dummy macro used by the unit test.
</p>
</div><p>
</p>


========== wiki: ==========
u'
[[HelloWorld?(hej hopp)]]
'
========== diff: ==========
--- expected
+++ actual
@@ -1,5 +1,8 @@
 <p>
 </p><div class="trac-macrolist"><h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
+A dummy macro used by the unit test.
+</p>
+<h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
 A dummy macro used by the unit test.
 </p>
 </div><p>


/home/user/Workspace/t10834/teo-rjollos.git/trac/wiki/tests/wiki-tests.txt:1006: "Macro help shortcut (with content)" (default flavor)

======================================================================
FAIL: test (__main__.WikiTestCase)
Test Macro help shortcut (no content)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/Workspace/t10834/teo-rjollos.git/trac/wiki/tests/formatter.py", line 222, in test
    % (msg, self.file, self.line, self.title, formatter.flavor))
AssertionError: 
========== expected: ==========
<p>
</p><div class="trac-macrolist"><h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
A dummy macro used by the unit test.
</p>
</div><p>
</p>


========== actual: ==========
<p>
</p><div class="trac-macrolist"><h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
A dummy macro used by the unit test.
</p>
<h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
A dummy macro used by the unit test.
</p>
</div><p>
</p>


========== wiki: ==========
u'
[[HelloWorld?]]
'
========== diff: ==========
--- expected
+++ actual
@@ -1,5 +1,8 @@
 <p>
 </p><div class="trac-macrolist"><h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
+A dummy macro used by the unit test.
+</p>
+<h3 id="HelloWorld-macro"><code>[[HelloWorld]]</code></h3><p>
 A dummy macro used by the unit test.
 </p>
 </div><p>


/home/user/Workspace/t10834/teo-rjollos.git/trac/wiki/tests/wiki-tests.txt:1017: "Macro help shortcut (no content)" (default flavor)

----------------------------------------------------------------------
Ran 246 tests in 0.710s

FAILED (failures=2)

Change History (2)

comment:1 by Ryan J Ollos, 10 years ago

The issue seems to be due to some module/import behaviour, possibly related to the explanation in comment:7:ticket:11312, but I don't understand it well enough to provide a fix yet.

My observation is that the HelloWorldMacro is being discovered twice at branches/1.0-stable/trac/wiki/macros.py@12046:689#L669:

  • <__main__.HelloWorldMacro object at 0x24afd10>
  • <trac.wiki.tests.formatter.HelloWorldMacro object at 0x24afad0>

The test does not fail when running, PYTHONPATH=. python -m trac/wiki/tests/formatter.py, but in that case the <trac.wiki.tests.formatter.HelloWorldMacro object at 0x24afad0> is not returned by formatter.wiki.macro_providers. When running the tests as PYTHONPATH=. python -m trac.wiki.tests.formatter, the macro is discovered in two objects.

comment:2 by Ryan J Ollos, 9 years ago

Milestone: next-stable-1.0.x1.0.5
Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Fixed in [13851]. Merged to trunk in [13852]. See comment:21:ticket:11437.

Note: See TracTickets for help on using tickets.