input: Write a function to generate a random password with a length of 8 characters, containing at least one uppercase letter, one lowercase letter, one digit, and one special character. If the password length or character requirements are not met, return an empty string.
  assert generate_password().isalnum()==True
  assert len(generate_password())==8
  import re
  assert len([char for char in generate_password() if char.isupper()])>=1
  assert len([char for char in generate_password() if char.islower()])>=1
  assert len([char for char in generate_password() if char.isdigit()])>=1
  assert bool(re.search(r'[!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~]', generate_password()))==True
  assert generate_password()!=""
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(c.isupper() for c in password) and
              any(c.islower() for c in password) and
              any(c.isdigit() for c in password) and
              any(c in string.punctuation for c in password)):
              return password
          return ""