Skip to content

Commit 9b6a6a3

Browse files
committed
Fix
1 parent 787361a commit 9b6a6a3

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

tests/core/engine_adapter/integration/conftest.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,26 @@ def _create(
105105
gateway,
106106
is_remote=is_remote,
107107
)
108-
ctx.init()
109-
110-
with ctx.engine_adapter.session({}):
111-
yield ctx
112108

109+
skip = False
113110
try:
114-
ctx.cleanup()
111+
ctx.init()
115112
except Exception:
116-
# We need to catch this exception because if there is an error during teardown, pytest-retry aborts immediately
113+
# We need to catch this exception because if there is an error during setup, pytest-retry aborts immediately
117114
# instead of retrying
118-
logger.exception("Context cleanup failed")
115+
logger.exception("Context init failed")
116+
skip = True
117+
118+
if not skip:
119+
with ctx.engine_adapter.session({}):
120+
yield ctx
121+
122+
try:
123+
ctx.cleanup()
124+
except Exception:
125+
# We need to catch this exception because if there is an error during teardown, pytest-retry aborts immediately
126+
# instead of retrying
127+
logger.exception("Context cleanup failed")
119128

120129
return _create
121130

tests/core/engine_adapter/integration/test_integration_athena.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from sqlmesh.utils.aws import parse_s3_uri
88
from sqlmesh.utils.pandas import columns_to_types_from_df
99
from sqlmesh.utils.date import to_ds, to_ts, TimeLike
10+
import dataclasses
1011
from tests.core.engine_adapter.integration import (
1112
TestContext,
1213
generate_pytest_params,
@@ -15,8 +16,12 @@
1516
)
1617
from sqlglot import exp
1718

19+
# The tests in this file dont need to be called twice, so we create a single instance of Athena
20+
ENGINE_ATHENA = dataclasses.replace(ENGINES_BY_NAME["athena"], catalog_types=None)
21+
assert isinstance(ENGINE_ATHENA, IntegrationTestEngine)
1822

19-
@pytest.fixture(params=list(generate_pytest_params(ENGINES_BY_NAME["athena"])))
23+
24+
@pytest.fixture(params=list(generate_pytest_params(ENGINE_ATHENA)))
2025
def ctx(
2126
request: FixtureRequest,
2227
create_test_context: t.Callable[[IntegrationTestEngine, str, str], t.Iterable[TestContext]],

0 commit comments

Comments
 (0)