conftest.py

Overview

The conftest.py file defines pytest fixtures used to manage dataset creation and cleanup during test execution for the InfiniFlow project. It provides reusable setup and teardown logic to create multiple datasets before tests run and ensure their deletion afterwards, maintaining test isolation and preventing side effects from persisting datasets.

Fixtures in this file leverage helper functions batch_create_datasets and delete_datasets from a common module to interact with the HTTP API authenticated via a get_http_api_auth fixture (assumed to be defined elsewhere in the test suite). Two fixtures with different scopes are provided:

Both fixtures ensure cleanup by deleting all datasets after the tests complete.


Detailed Explanation

Imports

Fixtures

add_datasets

@pytest.fixture(scope="class")
def add_datasets(get_http_api_auth, request):
    ...
@pytest.mark.usefixtures("add_datasets")
class TestDatasetOperations:
    def test_dataset_count(self, add_datasets):
        assert len(add_datasets) == 5

add_datasets_func

@pytest.fixture(scope="function")
def add_datasets_func(get_http_api_auth, request):
    ...
def test_modify_datasets(add_datasets_func):
    assert len(add_datasets_func) == 3
    # perform operations on datasets

Implementation Details


Interaction With Other Parts of the System


Mermaid Diagram: Flowchart of Fixture Workflow

flowchart TD
    subgraph Fixtures
        A[add_datasets (class scope)]
        B[add_datasets_func (function scope)]
    end

    subgraph Common Module
        C[batch_create_datasets]
        D[delete_datasets]
    end

    subgraph Test Execution
        E[Test functions/classes]
    end

    A --> C
    B --> C
    A -->|finalizer| D
    B -->|finalizer| D
    E --> A
    E --> B

Diagram Explanation:


Summary

The conftest.py file provides two pytest fixtures that manage dataset creation and deletion for testing the InfiniFlow API. It abstracts setup and teardown logic, promoting test isolation and reliability by ensuring datasets are consistently created and cleaned up. The fixtures differ in scope and dataset count to fit different test requirements. This modular approach simplifies test suite maintenance and reduces boilerplate code in individual tests.