input: Write a function to generate a random password of length 8, which consists of alphanumeric characters and at least one special character. If the generated password does not contain any special character, the function should regenerate it until it does.
  
  assert generate_password() != generate_password() # Ensure different passwords are generated each time
  assert len(generate_password()) == 8
  assert any([char in string.punctuation for char in generate_password()]) # Ensure at least one special character exists
  assert all([(char in string.ascii_letters or char in string.digits or char in string.punctuation) for char in generate_password()]) # Ensure the password contains only valid characters
output: import random
  import string
  
  def generate_password():
      while True:
          password = ''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=8))
          if any(char in string.punctuation for char in password):
              return password