Skip to main content

PyPi Waf Python Tests Black Flake8 Pip Install

Testing code that generates output can be tedious to maintain

pytest-datarecorder aims to simplify this task.

Installation

To install pytest-datarecorder:

pip install pytest-datarecorder

Usage

To make it easy to use in with py.test the DataRecorder object can be injected into a test function by using the datarecorder fixture.

Example:

def test_this_function(datarecorder):

    datarecorder.record_data(
        data={'a':1, 'b':2}, recording_file="test/data/recording.json")

The data passed will be serialized to JSON since the recording file has a .json extension. If data changes, we will get an exception containing a diff with what changed. If we want to accept the changes we simply delete the recording and run the code again.

Relase new version

  1. Edit NEWS.rst and wscript (set correct VERSION)

  2. Run

    ./waf upload

Source code

The main functionality is found in src/datarecorder.py and the corresponding unit test is in test/test_datarecorder.py if you want to play/modify/fix the code this would, in most cases, be the place to start.

Developer Notes

We try to make our projects as independent as possible of a local system setup. For example with our native code (C/C++) we compile as much as possible from source, since this makes us independent of what is currently installed (libraries etc.) on a specific machine.

To “fetch” sources we use Waf (https://waf.io/) augmented with dependency resolution capabilities: https://github.com/steinwurf/waf

The goal is to enable a work-flow where running:

./waf configure
./waf build --run_tests

Configures, builds and runs any available tests for a given project, such that you as a developer can start hacking at the code.

For Python project this is a bit unconventional, but we think it works well.

Tests

The tests will run automatically by passing --run_tests to waf:

./waf --run_tests

This follows what seems to be “best practice” advise, namely to install the package in editable mode in a virtualenv.

Notes

Release files for pytest-datarecorder 2.0.0

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

Built distribution (wheel)

Table of built distributions (wheels) for pytest-datarecorder 2.0.0
File Interpreter ABI Platform
pytest_datarecorder-2.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / pytest_datarecorder-2.0.0-py2.py3-none-any.whl

Download URL pytest_datarecorder-2.0.0-py2.py3-none-any.whl
Size 6.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ab9df04bf503860a46f3f483dba24266d82d205746b8a68e15ea19214a682772
BLAKE2b-256 checksum
How to use checksums
2644763ddf1605565cd17abf7277a250af8d5a9f398887855a2539b9cc107232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.6

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file

1.7.0

1 release file

1.6.0

1 release file

1.5.0

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.1

1 release file

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