Skip to content

Commit

Permalink
Remove schema from the engine used in tests for SQLite dialect (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet authored Feb 5, 2023
1 parent 5973ea3 commit 965d8d5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def copy_and_connect_sqlite_db(input_db, tmp_db, engine_echo):
shutil.copyfile(input_db, tmp_db)

db_url = f"sqlite:///{tmp_db}"
engine = create_engine(db_url, echo=engine_echo)
engine = create_engine(
db_url, echo=engine_echo, execution_options={"schema_translate_map": {"gis": None}}
)
listen(engine, "connect", load_spatialite)
with engine.begin() as connection:
print(
Expand Down
4 changes: 1 addition & 3 deletions tests/gallery/test_length_at_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# Tests imports
from tests import select
from tests import test_only_with_dialects

metadata = MetaData()

Expand All @@ -32,7 +31,6 @@
)


@test_only_with_dialects("postgresql")
class TestLengthAtInsert:
def test_query(self, conn):
metadata.drop_all(conn, checkfirst=True)
Expand All @@ -45,7 +43,7 @@ def test_query(self, conn):
]

# Define the query to compute distance (without spheroid)
distance = func.ST_Length(func.ST_GeomFromText(bindparam("ewkt")), False)
distance = func.ST_Length(func.ST_GeomFromEWKT(bindparam("ewkt")), False)

i = table.insert()
i = i.values(geom=bindparam("ewkt"), distance=distance)
Expand Down
16 changes: 16 additions & 0 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ def test_no_geom_type(self, conn):
# Drop the table
t.drop(bind=conn)

def test_explicit_schema(self, conn):
# Define the table
t = Table(
"a_table",
MetaData(),
Column("id", Integer, primary_key=True),
Column("geom", Geometry()),
schema="gis",
)

# Create the table
t.create(bind=conn)

# Drop the table
t.drop(bind=conn)

@test_only_with_dialects("postgresql")
def test_common_dialect(self, conn, monkeypatch, metadata, Lake):
monkeypatch.setattr(conn.dialect, "name", "UNKNOWN DIALECT")
Expand Down

0 comments on commit 965d8d5

Please sign in to comment.