"""
+ # A friendly error warning instead of an AttributeError in case fetch()
+ # failed and it wasn't noticed.
+ if not info:
+ raise TypeError("no info passed. Is the 'postgis' extension loaded?")
+
info.register(context)
adapters = context.adapters if context else postgres.adapters
# Generate and register the text and binary dumper
conn.execute("SELECT pg_typeof(%s)", [point]).fetchone()[0]
+def test_no_info_error(conn):
+ from psycopg.types.shapely import register_shapely
+
+ with pytest.raises(TypeError, match="postgis.*extension"):
+ register_shapely(None, conn)
+
+
def test_with_adapter(shapely_conn):
SAMPLE_POINT = Point(1.2, 3.4)
SAMPLE_POLYGON = Polygon([(0, 0), (1, 1), (1, 0)])