fix: add null safety check to URL construction in test_login.py

- Add explicit check for ERP_URL environment variable
- Prevent AttributeError when ERP_URL is not set
- Provide clear error message for missing configuration

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-03-27 12:47:10 +08:00
parent fa33bee3e1
commit 8048f2e669

View File

@@ -32,7 +32,10 @@ print(f" Headless: {os.getenv('ERP_HEADLESS')}")
print(f" Ignore HTTPS Errors: {os.getenv('ERP_IGNORE_HTTPS_ERRORS')}") print(f" Ignore HTTPS Errors: {os.getenv('ERP_IGNORE_HTTPS_ERRORS')}")
# Construct complete login URL # Construct complete login URL
url = f"{os.getenv('ERP_URL').rstrip('/')}/yonbip/resources/uap/rbac/login/main/index.html" base_url = os.getenv('ERP_URL')
if not base_url:
raise ValueError("ERP_URL environment variable is required")
url = f"{base_url.rstrip('/')}/yonbip/resources/uap/rbac/login/main/index.html"
try: try:
with sync_playwright() as p: with sync_playwright() as p: