Skip to main content

Simple pytest plugin to look for regex in Exceptions

Project description

travis Supported Python versions Latest Version MIT License Downloads Wheel package

I really missed assertRaisesRegexp in unittest module from pytest, so I wrote this simple plugin.

Usage

# some_module.py
class ExpectedException(Exception):
    pass

def function_to_test():
    raise ExpectedException('error message: 1560')
# test_some_module.py
from pytest import raises_regexp
from some_module import function_to_test, ExpectedException

def test_something_to_test():
    with raises_regexp(ExpectedException, r".* 1560"):
        function_to_test()

Installation

$ pip install pytest-raisesregexp

It installs as a pytest entry point, so you can:

from pytest import raises_regexp

LICENSE

MIT license Copyright (c) 2013-2014 Kiss György

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-raisesregexp, version 2.0
Filename, size File type Python version Upload date Hashes
Filename, size pytest_raisesregexp-2.0-py2-none-any.whl (4.6 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size pytest_raisesregexp-2.0-py3-none-any.whl (4.6 kB) File type Wheel Python version 3.4 Upload date Hashes View
Filename, size pytest-raisesregexp-2.0.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page