This directory contains the testing infrastructure for TensorFlow Transform.
tests/
├── README.md # This file
├── __init__.py # Package marker
├── conftest.py # Shared pytest fixtures and configuration
├── test_setup_validation.py # Full validation tests (requires all dependencies)
├── test_minimal_setup.py # Minimal tests that work without all dependencies
├── unit/ # Unit tests directory
│ └── __init__.py
└── integration/ # Integration tests directory
└── __init__.py
# Run all tests
poetry run test
# Alternative command (both work)
poetry run tests
# Run specific test file
poetry run test tests/test_minimal_setup.py
# Run with specific markers
poetry run test -m unit
poetry run test -m "not slow"# Run all tests
python -m pytest
# Run with coverage
python -m pytest --cov=tensorflow_transform
# Run without coverage (useful for debugging)
python -m pytest --no-cov@pytest.mark.unit- Fast, isolated unit tests@pytest.mark.integration- Integration tests that may require external resources@pytest.mark.slow- Tests that take a long time to run
See conftest.py for all available fixtures. Key fixtures include:
temp_dir- Temporary directory that's cleaned up after testtemp_file- Temporary file that's cleaned up after testmock_config- Sample configuration dictionarysample_data- Sample data for testing transformationstf_example_data- Temporary TFRecord file with example datamock_preprocessing_fn- Simple preprocessing function for testingmock_schema- Simple schema for testing
Coverage is configured to:
- Require 80% minimum coverage
- Generate HTML reports in
htmlcov/ - Generate XML report as
coverage.xml - Exclude test files and common patterns from coverage
Some dependencies like tfx-bsl may not have pre-built wheels for ARM64 architecture (e.g., Apple Silicon Macs, ARM Linux). If you encounter installation issues:
- Try running the minimal test suite:
poetry run test tests/test_minimal_setup.py --no-cov - Consider using x86_64 emulation or a compatible environment
- Build dependencies from source if needed
- Place unit tests in
tests/unit/ - Place integration tests in
tests/integration/ - Use appropriate markers (
@pytest.mark.unit, etc.) - Import and use fixtures from
conftest.py - Follow existing test patterns and naming conventions