feat: Set up comprehensive Python testing infrastructure with Poetry #341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Comprehensive Python Testing Infrastructure
Summary
This PR sets up a complete testing infrastructure for the TensorFlow Transform project, migrating from the legacy setup.py to modern Poetry package management and adding pytest as the primary testing framework.
Changes Made
Package Management Migration
pyproject.toml
with Poetry configurationsetup.py
to Poetry formatTesting Framework Setup
Testing Configuration
Created comprehensive pytest configuration in
pyproject.toml
:test_*.py
and*_test.py
filesunit
- Fast, isolated unit testsintegration
- Tests requiring external resourcesslow
- Long-running testsDirectory Structure
Shared Testing Fixtures
Created comprehensive fixtures in
conftest.py
:temp_dir
- Temporary directory managementtemp_file
- Temporary file handlingmock_config
- Sample configuration datasample_data
- Test data for transformationstf_example_data
- TFRecord test data generationmock_preprocessing_fn
- Sample preprocessing functionmock_schema
- TensorFlow metadata schema fixtureDevelopment Workflow
Configured Poetry scripts for consistent test execution:
Both commands support all standard pytest options:
Documentation
.gitignore
with testing artifacts and development filestests/README.md
with:Testing the Setup
Validation tests have been created and verified:
Known Issues
ARM64 Architecture Support
Some dependencies (particularly
tfx-bsl
) may not have pre-built wheels for ARM64 architectures. This affects:Workarounds are documented in
tests/README.md
.Next Steps
With this infrastructure in place, developers can now:
tests/unit/
directorytests/integration/
directoryThe testing infrastructure is ready for immediate use - developers can start writing tests using the established patterns and fixtures.