Skip to main content

One function that makes the string matchable

Project description

full_match

Downloads Downloads codecov Lines of code Hits-of-Code Test-Package Python versions PyPI version Checked with mypy Ruff

When catching exceptions in Pytest, sometimes you need to check messages. Since the user sends a pattern for searching, and not a message for exact matching, sometimes similar, but not identical messages pass through the filter. This micro-library contains a function that makes Pytest check exception messages accurately.

It may also be useful to you if you use mutation testing tools such as mutmut.

Install it:

pip install full_match

And use:

import pytest
import full_match

def test_something():
  with pytest.raises(AssertionError, match='Regex pattern did not match.'):
    with pytest.raises(ValueError, match=full_match('Some message.')):
      raise ValueError('XXSome message.XX')

The message in the inner with block does not match the pattern exactly, so an AssertionError exception will occur in this example.

Project details


Download files

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

Source Distribution

full_match-0.0.1.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

full_match-0.0.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page