Add tests/compat.py for test-only imports
Merge pull request #2442 from danielgtaylor/test-compat

Add tests/compat.py for test-only imports. Fixes #2442.