TestingΒΆ

The pyroapi package includes tests to ensure new backends conform to the standard API, indeed these tests serve as the formal API description. To add tests to your new backend say in project/test/ follow these steps (or see the example in funsor):

  1. Create a new directory project/test/pyroapi/.
  2. Create a file project/test/pyroapi/conftest.py and a hook to treat missing features as xfail:
import pytest


def pytest_runtest_call(item):
    try:
        item.runtest()
    except NotImplementedError as e:
        pytest.xfail(str(e))
  1. Create a file project/test/pyroapi/test_pyroapi.py and define a backend fixture:
import pytest
from pyroapi import pyro_backend
from pyroapi.tests import *  # noqa F401

@pytest.yield_fixture
def backend():
    with pyro_backend("my_backend"):
        yield
  1. Test your backend with pytest
pytest -vx test/pyroapi