From c791afbc2410eeb0fff216f1ffb58384639e7beb Mon Sep 17 00:00:00 2001 From: Marcin Raba Date: Wed, 23 Oct 2024 15:47:32 +0200 Subject: [PATCH] mraba/underscore_column_id: test fix 3 --- tests/test_compiler.py | 15 --------------- tests/test_quote_identifiers.py | 27 +++++++-------------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/tests/test_compiler.py b/tests/test_compiler.py index 7a0735ff..55451c2f 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -33,21 +33,6 @@ def test_now_func(self): dialect="snowflake", ) - def test_dot_as_valid_identifier(self): - _table = table( - "table_1745924", - column("ca", Integer), - column("cb", String), - column(".", String), - ) - - stmt = insert(_table).values({"ca": 1, "cb": "test", ".": "test_"}) - self.assert_compile( - stmt, - 'INSERT INTO table_1745924 (ca, cb, ".") VALUES (%(ca)s, %(cb)s, %(_)s)', - dialect="snowflake", - ) - def test_underscore_as_valid_identifier(self): _table = table( "table_1745924", diff --git a/tests/test_quote_identifiers.py b/tests/test_quote_identifiers.py index 741741a4..58575fad 100644 --- a/tests/test_quote_identifiers.py +++ b/tests/test_quote_identifiers.py @@ -1,20 +1,9 @@ # # Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. -import pytest -from sqlalchemy import ( - Column, - Integer, - MetaData, - String, - Table, - create_engine, - insert, - select, -) - -from snowflake.sqlalchemy import URL -from .parameters import CONNECTION_PARAMETERS +# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. +import pytest +from sqlalchemy import Column, Integer, MetaData, String, Table, insert, select @pytest.mark.parametrize( @@ -24,7 +13,7 @@ pytest.param(".", id="dot"), ), ) -def test_insert_with_identifier_as_column_name(identifier: str): +def test_insert_with_identifier_as_column_name(identifier: str, engine_testaccount): expected_identifier = f"test: {identifier}" metadata = MetaData() table = Table( @@ -35,12 +24,10 @@ def test_insert_with_identifier_as_column_name(identifier: str): Column(identifier, String), ) - engine = create_engine(URL(**CONNECTION_PARAMETERS)) - try: - metadata.create_all(engine) + metadata.create_all(engine_testaccount) - with engine.connect() as connection: + with engine_testaccount.connect() as connection: connection.execute( insert(table).values( { @@ -53,4 +40,4 @@ def test_insert_with_identifier_as_column_name(identifier: str): result = connection.execute(select(table)).fetchall() assert result == [(1, "test", expected_identifier)] finally: - metadata.drop_all(engine) + metadata.drop_all(engine_testaccount)