[TIP] unittest2 expectedFailure

Florian Bruhin me at the-compiler.org
Sat Aug 1 03:06:32 PDT 2015

* Aaron Whitehouse <lists at whitehouse.kiwi.nz> [2015-08-01 10:55:27 +0100]:
> 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.

Hmm... unittest2 at least seems to implement it:


> My relevant code is:
> import sys
> if sys.version_info < (2, 7):
>     import unittest2 as unittest
> else:
>     import unittest
> @unittest.expectedFailure
> def test_expected_failure(self):
>     """Test behaviour of expectedFailure"""
>     self.assertEqual(1, 2)

Is that actually the code you're running? I don't see a class
inheriting from unittest.TestCase here, so unittest doesn't find and
tests here for me (as it requires tests to be in classes).

By the way: Have you ever considered switching to an alternative test
framework which works on older versions with all features
out-of-the-box? I can highly recommend py.test: http://www.pytest.org/

(In my opinion, it's also a lot more pleasant to use than unittest is)


http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20150801/13ffa5a2/attachment.pgp>

More information about the testing-in-python mailing list