From 14b1e6fe8e18d139846c1aba6761d4eea3dc25c3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 28 Jan 2016 17:59:48 -0500 Subject: [PATCH] - use a StaticPool for componentreflectiontest to ensure temp tables are reflectable on the same session they were created --- .../testing/suite/test_reflection.py | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py index 288a859736..4a3dd90240 100644 --- a/lib/sqlalchemy/testing/suite/test_reflection.py +++ b/lib/sqlalchemy/testing/suite/test_reflection.py @@ -39,6 +39,15 @@ class ComponentReflectionTest(fixtures.TablesTest): __backend__ = True + @classmethod + def setup_bind(cls): + if config.requirements.independent_connections.enabled: + from sqlalchemy import pool + return engines.testing_engine( + options=dict(poolclass=pool.StaticPool)) + else: + return config.db + @classmethod def define_tables(cls, metadata): cls.define_reflected_tables(metadata, None) @@ -104,7 +113,7 @@ class ComponentReflectionTest(fixtures.TablesTest): # temp table fixture if testing.against("oracle"): kw = { - 'prefixes': ["GLOBAL TEMPORARY"], + 'prefixes': ["TEMPORARY"], 'oracle_on_commit': 'PRESERVE ROWS' } else: @@ -202,7 +211,7 @@ class ComponentReflectionTest(fixtures.TablesTest): @testing.requires.temp_table_names def test_get_temp_table_names(self): - insp = inspect(testing.db) + insp = inspect(self.bind) temp_table_names = insp.get_temp_table_names() eq_(sorted(temp_table_names), ['user_tmp']) @@ -210,7 +219,7 @@ class ComponentReflectionTest(fixtures.TablesTest): @testing.requires.temp_table_names @testing.requires.temporary_views def test_get_temp_view_names(self): - insp = inspect(self.metadata.bind) + insp = inspect(self.bind) temp_table_names = insp.get_temp_view_names() eq_(sorted(temp_table_names), ['user_tmp_v']) @@ -348,7 +357,7 @@ class ComponentReflectionTest(fixtures.TablesTest): @testing.requires.temp_table_reflection def test_get_temp_table_columns(self): - meta = MetaData(testing.db) + meta = MetaData(self.bind) user_tmp = self.tables.user_tmp insp = inspect(meta.bind) cols = insp.get_columns('user_tmp') @@ -361,7 +370,7 @@ class ComponentReflectionTest(fixtures.TablesTest): @testing.requires.view_column_reflection @testing.requires.temporary_views def test_get_temp_view_columns(self): - insp = inspect(self.metadata.bind) + insp = inspect(self.bind) cols = insp.get_columns('user_tmp_v') eq_( [col['name'] for col in cols], @@ -503,7 +512,7 @@ class ComponentReflectionTest(fixtures.TablesTest): @testing.requires.temp_table_reflection @testing.requires.unique_constraint_reflection def test_get_temp_table_unique_constraints(self): - insp = inspect(self.metadata.bind) + insp = inspect(self.bind) reflected = insp.get_unique_constraints('user_tmp') for refl in reflected: # Different dialects handle duplicate index and constraints @@ -513,7 +522,7 @@ class ComponentReflectionTest(fixtures.TablesTest): @testing.requires.temp_table_reflection def test_get_temp_table_indexes(self): - insp = inspect(self.metadata.bind) + insp = inspect(self.bind) indexes = insp.get_indexes('user_tmp') for ind in indexes: ind.pop('dialect_options', None) -- 2.47.2