Registry / testing / pytest-expect-test

pytest-expect-test

JSON →
library0.1.0pypypi✓ verified 88d ago

A lightweight pytest plugin providing an `expect` fixture for snapshot testing. Version 0.1.0 is the initial release, requiring Python >=3.5. Development appears low-frequency, with no recent updates.

pip install pytest-expect-test
INSTALL
IMPORT
SIG · PYTEST-EXPECT-TEST
P
pytest-expect-test
testingpythonv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

expect
✓ from pytest_expect_test import expect
✗ import pytest_expect_test
Direct import of the module gives pytest plugin; the fixture needs explicit import.

Basic usage: use the `expect` fixture to assert equality. On first run, the expected value is recorded; later runs check against the recorded snapshot.

def test_example(expect): expect(2 + 2) == 4 # The first run records the expectation, subsequent runs compare.
Debug
Known issues
gotchaOn first test run, the test passes regardless of the actual value because the expectation is recorded. Subsequent runs will fail if the actual value differs from recorded.
fix
Review the recorded expectations (typically stored in test directory) and commit them to version control.
affects: 0.1.0
gotchaThe `expect` fixture must be used as a parameter in the test function; it is not a regular assertion. Do not call `expect()` as a function without the fixture injection.
fix
Define test with `def test_foo(expect):` to inject the fixture.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'expect'
Attempting to import `expect` directly from `pytest` or without installing the plugin.
fix
Run `pip install pytest-expect-test` and use `from pytest_expect_test import expect`.
AttributeError: 'Test' object has no attribute 'expect'
Using `self.expect` inside a test method in a class while `expect` is passed as a parameter. Not supported as class attribute.
fix
Use `expect` as a function parameter in the test method: `def test_example(self, expect): expect(...)`
Upgrade
Version history
0.1.0latest on PyPI · released Apr 10, 2023
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
pytest-expect-test — pip install pytest-expect-test · libregistry