Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Test pypdf dependency for PDF processing functionality | |
""" | |
def test_pypdf_import(): | |
"""Test that pypdf can be imported successfully.""" | |
try: | |
import pypdf | |
print("β pypdf import successful") | |
print(f"β pypdf version: {pypdf.__version__}") | |
return True | |
except ImportError as e: | |
print(f"β pypdf import failed: {e}") | |
return False | |
def test_pypdf_basic_functionality(): | |
"""Test basic pypdf functionality.""" | |
try: | |
from pypdf import PdfReader | |
print("β PdfReader import successful") | |
# Test that we can create a PdfReader instance (without actual file) | |
print("β pypdf basic functionality available") | |
return True | |
except Exception as e: | |
print(f"β pypdf functionality test failed: {e}") | |
return False | |
def main(): | |
"""Run pypdf dependency tests.""" | |
print("π Testing pypdf dependency...") | |
tests = [ | |
("pypdf Import", test_pypdf_import), | |
("pypdf Functionality", test_pypdf_basic_functionality) | |
] | |
passed = 0 | |
total = len(tests) | |
for test_name, test_func in tests: | |
if test_func(): | |
passed += 1 | |
print(f"β {test_name}: PASSED") | |
else: | |
print(f"β {test_name}: FAILED") | |
print(f"\nπ pypdf Tests: {passed}/{total} passed") | |
if passed == total: | |
print("π pypdf dependency ready for PDF processing!") | |
return True | |
else: | |
print("β οΈ pypdf dependency issues detected") | |
return False | |
if __name__ == "__main__": | |
success = main() | |
exit(0 if success else 1) |