Skipped PostGIS version tests when psycopg2 not installed

Refs #22334. Thanks Tim Graham for spotting the issue.