#!/usr/bin/env python3 """Comprehensive test suite for email_validator.py""" import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) from email_validator import is_valid_email, validate_email # Test cases: (email, expected_valid) tests = [ # Valid emails ("user@example.com", True), ("test.email@domain.co.uk", True), ("user+tag@example.org", True), ("UPPERCASE@EXAMPLE.COM", True), ("user123@test-site.net", True), # Invalid emails ("", False), ("invalid", False), ("@missing-local.com", False), ("missing-at-sign.com", False), ("user@", False), ("user@.com", False), (" ", False), (None, False), ] all_passed = True print("Running email validation tests...") for email, expected in tests: result = is_valid_email(email) status = "PASS" if result == expected else "FAIL" if result != expected: all_passed = False print(f" [{status}] {repr(email)}: got {result}, expected {expected}") print(f"\nAll tests passed: {all_passed}") sys.exit(0 if all_passed else 1)