<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
You may remember that I posted recently about using Tox to run our
unittests against both Python 2.6 and Python 2.7. <br>
<br>
That now seems to be working, but I'm running into difficulty with
the @unittest.expectedFailure decorator. It appears to be working as
expected in Python 2.7, but not in Python 2.6 using unittest2.<br>
<br>
My relevant code is:<br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<pre style="background-color:#ffffff;color:#000000;font-family:'DejaVu Sans Mono';font-size:9.0pt;"><span style="color:#000080;font-weight:bold;">import </span>sys
<span style="color:#000080;font-weight:bold;">if </span>sys.version_info < (<span style="color:#0000ff;">2</span>, <span style="color:#0000ff;">7</span>):
<span style="color:#000080;font-weight:bold;">import </span>unittest2 <span style="color:#000080;font-weight:bold;">as </span>unittest
<span style="color:#000080;font-weight:bold;">else</span>:
<span style="color:#000080;font-weight:bold;">import </span><span style="background-color:#e4e4ff;">unittest
</span><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8">@<span style="color:#0000b2;">unittest.expectedFailure
</span><span style="color:#000080;font-weight:bold;">def </span>test_expected_failure(<span style="color:#94558d;">self</span>):
<span style="color:#808080;font-style:italic;">"""Test behaviour of expectedFailure"""
</span><span style="color:#808080;font-style:italic;"> </span><span style="color:#94558d;">self</span>.assertEqual(<span style="color:#0000ff;">1</span>, <span style="color:#0000ff;">2</span>)<pre style="background-color:#ffffff;color:#000000;font-family:'DejaVu Sans Mono';font-size:9.0pt;"></pre>
</pre>
When I run this, it gives an expected failure on Python 2.7, but an
error on Python 2.6.<br>
$ tox -- -s testing.unit.test_diffdir.DDTest.test_expected_failure<br>
[...]<br>
Test behaviour of expectedFailure ... FAIL<br>
<br>
======================================================================<br>
FAIL: Test behaviour of expectedFailure<br>
----------------------------------------------------------------------<br>
Traceback (most recent call last):<br>
File
"/home/aaron/Programming/duplicity_fix_tests/testing/unit/test_diffdir.py",
line 139, in test_expected_failure<br>
self.assertEqual(1, 2)<br>
AssertionError: 1 != 2<br>
<br>
----------------------------------------------------------------------<br>
Ran 1 test in 0.124s<br>
<br>
FAILED (failures=1)<br>
<br>
[...]<br>
<br>
Test behaviour of expectedFailure ... expected failure<br>
<br>
----------------------------------------------------------------------<br>
Ran 1 test in 0.126s<br>
<br>
OK (expected failures=1)<br>
___________________________________ summary
____________________________________<br>
ERROR: py26: commands failed<br>
py27: commands succeeded<br>
<br>
<br>
I thought that the intention was that these two modules acted in the
same way. Have I done something incorrectly, or have I misunderstood
something?<br>
<br>
Many thanks,<br>
<br>
Aaron<br>
</body>
</html>