Skip to main content

This is a fork of garybernhardt/expecter that hides the internal stack trace for pytest.

Overview

This lets you write tests (using ropez/pytest-describe) like this:

from expecter import expect


def describe_foobar():

    def it_can_pass():
        expect(2 + 3) == 5

    def it_can_fail():
        expect(2 + 3) == 6

and instead of getting output like this:

=================================== FAILURES ===================================
_________________________ describe_foobar.it_can_fail __________________________

    def it_can_fail():
>       expect(2 + 3) == 6

test_expecter.py:14:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = expect(3), other = 4

    def __eq__(self, other):
        msg = 'Expected %s but got %s' % (repr(other), repr(self._actual))
        if (isinstance(other, basestring) and
                isinstance(self._actual, basestring)):
            msg += normalized_diff(other, self._actual)
        elif len(repr(self._actual)) > 74:
            msg += normalized_diff(pprint.pformat(other),
                                   pprint.pformat(self._actual))
>       assert self._actual == other, msg
E       AssertionError: Expected 6 but got 5

env/lib/python3.5/site-packages/expecter.py:57: AssertionError
====================== 1 failed, 1 passed in 2.67 seconds ======================

getting output like this:

=================================== FAILURES ===================================
_________________________ describe_foobar.it_can_fail __________________________

    def it_can_fail():
>       expect(2 + 3) == 6
E       AssertionError: Expected 6 but got 5

test_expecter.py:14: AssertionError
====================== 1 failed, 1 passed in 2.67 seconds ======================

Installation

pip install pytest-expecter

Versioning

This plugin’s version number will follow expecter:

M.N.P-F

where:

  • M.N.P is the version of expecter included in the plugin

  • F is incremented on each release of the plugin for that version

Metadata

Release files for pytest-expecter 0.2.2.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-expecter 0.2.2.post1
File Size Uploaded
pytest-expecter-0.2.2.post1.tar.gz 4.1 kB Details

Release files / pytest-expecter-0.2.2.post1.tar.gz

Download URL pytest-expecter-0.2.2.post1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1868e755f3a1d21febeafe0a73f073c503f77205c79be605f43680d3771e12c2
BLAKE2b-256 checksum
How to use checksums
ca68888650f2a63fd5a76bdf0b357d9d60db715a5df4126663f720fa816e025c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page