Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-25 08:29:08

0001 #!/usr/bin/env python3
0002 """Run tests for swf-common-lib repository."""
0003 import os
0004 import sys
0005 import subprocess
0006 from pathlib import Path
0007 
0008 def print_separator():
0009     """Print the 100-character separator line."""
0010     print("\n" + "*" * 100 + "\n")
0011 
0012 def main():
0013     """Main function."""
0014     print_separator()
0015     
0016     # Get the directory of this script
0017     script_dir = Path(__file__).resolve().parent
0018     
0019     # Check if we're in a virtual environment or use testbed's venv
0020     if "VIRTUAL_ENV" not in os.environ:
0021         # Look for swf-testbed's virtual environment
0022         swf_parent_dir = os.environ.get("SWF_PARENT_DIR", script_dir.parent)
0023         testbed_venv = Path(swf_parent_dir) / "swf-testbed" / ".venv"
0024         
0025         if testbed_venv.exists():
0026             print("🔧 Using swf-testbed virtual environment...")
0027             venv_python = testbed_venv / "bin" / "python"
0028             if venv_python.exists():
0029                 os.environ["VIRTUAL_ENV"] = str(testbed_venv)
0030                 os.environ["PATH"] = f"{testbed_venv}/bin:{os.environ['PATH']}"
0031                 sys.executable = str(venv_python)
0032         else:
0033             print("❌ Error: No Python virtual environment found")
0034             print("   Please activate the swf-testbed virtual environment first:")
0035             print("   cd swf-testbed && source .venv/bin/activate")
0036             return 1
0037     
0038     print(f"Using Python environment: {os.environ.get('VIRTUAL_ENV', 'system')}")
0039     print("Running pytest for swf-common-lib...")
0040     
0041     # Run pytest using the current Python interpreter
0042     result = subprocess.run([sys.executable, "-m", "pytest"], cwd=script_dir)
0043     return result.returncode
0044 
0045 if __name__ == "__main__":
0046     sys.exit(main())