Skip to content

8451/labrea-test

Repository files navigation

Labrea Test

Utilities for testing code written with labrea

lifecycle PyPI Downloads pre-commit Coverage docs

Installation

labrea-test is available for install via pip.

pip install labrea-test

Alternatively, you can install the latest development version from GitHub.

pip install git+https://github.com/8451/labrea-test@develop

Usage

During testing, you may want to mock a certain dataset (or other Evaluatable) to known value. This can be done using the labrea_test.Mock context manager, which ensures that at the end of the block, any mocking is torn down.

import labrea_test
from labrea import dataset


@dataset
def foo() -> str:
    return "foo"


def test_foo():
    with labrea_test.Mock() as mock:
        mock(foo, "bar")
        assert foo() == "bar"

    assert foo() == "foo"

Mock can be used to mock any Evaluatable object, and can take a plain value or another Evaluatable object as the value to mock to.

@dataset
def bar() -> str:
    return "bar"


def test_foo():
    with labrea_test.Mock() as mock:
        mock(foo, bar)
        assert foo() == "bar"

    assert foo() == "foo"

Contributing

If you would like to contribute to labrea-test, please read the Contributing Guide.

Changelog

A summary of recent updates to labrea-test can be found in the Changelog.

Maintainers

Maintainer Email
Austin Warner austin.warner@8451.com
Michael Stoepel michael.stoepel@8451.com

Links

About

Utilities for testing code written with labrea

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages