This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

XFail provides a decorator function xfail to skip expected exceptions. Similar to unittest.skipIf, but xfail can specify which exception should be skipped, and raise if the decorated function is unexpectedly passed (only if strict is True).

Install

Supported python versions are: 2.7, 3.4, 3.5

Can be installed from PyPI by pip:

pip install xfail

Usage

xfail decorator

xfail accepts two arguments, exceptions and strict.

The first argument (exceptions) should be an Exception class to skip (Ex. Exception, AssertionError, and so on). If you want to skip multiple exceptions, use tuple of them, for example, @xfail((AssertionError, ValueError)).

The second argument strict should be a boolean. If strict is False (by default) and passed unexpectedly, raise unittest.SkipTest exception, which will mark the test is skipped. This case is very similar to the function is decorated by uniteest.skip function and the test will be counted as skipped.

If it is True and the decorated function did not raise (any of) the expected exception(s), XPassFailure exception would be raised. In this case, the test will be counted as fail.
from xfail import xfail

@xfail(IndexError)
def get(l, index):
    return l[index]

l = [1, 2, 3]
get(4)  # no error

Also supports multiple exceptions:

@xfail((IndexError, ValueError))
def a():
    '''This function passes IndexError and ValueError
    ...

In test script, similar to unittest.TestCase.assertRaises:

from unittest import TestCase
from xfail import xfail

class MyTest(TestCase):
    def test_1(self):
        @xfail(AssertionError)
        def should_raise_error():
            assert False
        a()  # test passes

    def test_2(self):
        @xfail(AssertionError, strict=True)
        def should_raise_error():
            assert True
        a()  # test failes, since this function should raise AssertionError

    # Can be used for test function
    @xfail(AssertionError, strict=True)
    def test_3(self)
        assert False

    # This test will fail
    @xfail(AssertionError, strict=True)
    def test_3(self)
        assert True

For more exapmles, see test_xfail.py.

Release History

Release History

1.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
xfail-1.1.0.tar.gz (3.0 kB) Copy SHA256 Checksum SHA256 Source May 3, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting