Skip to content

Introduction to pytest-f3ts

pipeline status

Latest Release

pytest-f3ts is a pytest plugin developed to extend the standard capabilities of pytest for hardware testing applications. This plugin is particularly useful in the context of Printed Circuit Board Assembly (PCBA) functional testing during the manufacturing process. It integrates smoothly with existing pytest workflows, bringing additional functionality tailored for hardware test environments.

FixturFab Test Runner is also supported out of the box, providing an easy to use interface for running and managing tests on the factory floor.

Installation

The easiest way to install pytest-f3ts is via pip:

bash
pip install pytest-f3ts

You can also install the latest development version directly from the source code repository:

bash
pip install git+https://gitlab.com/fixturfab/software/pytest-f3ts.git

Basic Test Plan Structure

The simplest structure for a hardware test plan consists of just a single python file that follows pytest naming convention, for example: test_my_dut.py.

Within this file, the Test Interface fixture, the object that will control any test hardware, will need to be created, and the test cases will also need to be added. For example, a simple test case where a 5V voltage would be measured and validated could be implemented as follows:

python
import pytest

# Import the DMM class from your library
from .instruments import DMM


# Set the interface fixture to be created only once during a test,
# this prevents the test hardware from needing to be opened/closed
# for every test case.
@pytest.fixture(scope="session")
def interface(request):
    # Open the instrumentation that is required for the test
    my_dmm = DMM()

    # Define a teardown method that will be used too close the object
    # when the test plan has finished.
    def teardown():
        my_dmm.close()

    # Add the teardown method as a finalizer
    request.addfinalizer(teardown)

    # Return the created instrumentation
    return my_dmm


# Create a test case to measure 5V from channel 1 of the DMM
def test_channel_1_voltage(interface):
    # Measure the voltage on the DMM
    meas = interface.get_voltage(1)

    # Check that the voltage is within set limits
    assert meas > 4.9
    assert meas < 5.1

You can then run the test using the pytest command:

bash
pytest test_my_dut.py