# test_imports.py import sys import os # Optional: Explicitly add project root to path if needed, # although running from the root often suffices. # project_root = os.path.dirname(__file__) # if project_root not in sys.path: # sys.path.insert(0, project_root) print("Attempting imports...") try: # Try importing the main entry point for bs4 from the lib structure from lib.bs4 import BeautifulSoup print("- Successfully imported BeautifulSoup from lib.bs4") # Try creating a simple soup object (tests basic bs4 internal imports) soup = BeautifulSoup("", "html.parser") print(f"- Created soup object: {soup.a}") # Try importing the main entry point for soupsieve from lib.soupsieve import compile as soupsieve_compile print("- Successfully imported compile from lib.soupsieve") # Try compiling a simple selector (tests basic soupsieve internal imports) compiled = soupsieve_compile("a") print(f"- Compiled selector: {compiled.pattern}") # Try using the selector (tests soupsieve -> bs4 interaction) match = compiled.select_one(soup) print(f"- Selector match: {match}") print("\nBasic import and usage tests passed!") except ImportError as e: print(f"\nImport Error: {e}") print("Failed to import. Check paths and internal library structure.") except Exception as e: print(f"\nRuntime Error: {e}") print("Imports might have worked, but usage failed.")