Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove schema from the engine used in tests for SQLite dialect #426

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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