mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-04-28 15:13:23 -05:00
This change ensures tests run immediately when developing modules but don't execute when modules are imported by other modules. Changes: - Protected all test executions with if __name__ == "__main__" blocks - Unit tests run immediately after function definitions during development - Module integration test (test_module()) runs at end when executed directly - Updated module-developer.md with new testing patterns and examples Benefits: - Students see immediate feedback when developing (python module_dev.py runs all tests) - Clean imports: later modules can import earlier ones without triggering tests - Maintains educational flow: tests visible right after implementations - Compatible with nbgrader and notebook environments Tested: - Module 01 runs all tests when executed directly ✓ - Importing Tensor from tensor_dev doesn't run tests ✓ - Cross-module imports work without test interference ✓