Skip to content

Commit

Permalink
Skip SQL count check in test (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jdu authored Jun 4, 2024
1 parent 903eee2 commit e7813c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 12 additions & 0 deletions tests/integ/modin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def pytest_addoption(parser):
parser.addoption(
"--generate_pandas_api_coverage", action="store_true", default=False
)
parser.addoption("--skip_sql_count_check", action="store_true", default=False)


@pytest.fixture(scope="session", autouse=True)
Expand All @@ -54,6 +55,17 @@ def setup_pandas_api_coverage_generator(pytestconfig):
PandasAPICoverageGenerator()


SKIP_SQL_COUNT_CHECK = False


@pytest.fixture(scope="session", autouse=True)
def setup_skip_sql_count_check(pytestconfig):
skip = pytestconfig.getoption("skip_sql_count_check")
if skip:
global SKIP_SQL_COUNT_CHECK
SKIP_SQL_COUNT_CHECK = True


@pytest.fixture(scope="function")
def sql_counter():
"""Return a sql counter as pytest fixture"""
Expand Down
14 changes: 7 additions & 7 deletions tests/integ/modin/sql_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ def __init__(
high_count_reason=None,
**kwargs,
) -> "SqlCounter":
from tests.integ.modin.conftest import SKIP_SQL_COUNT_CHECK

self._queries: list[QueryRecord] = []
self._no_check = no_check

# Bypassing sql counter since
# 1. it is an unnecessary metric for tests running in stored procedures
# 2. pytest-assume package is not available in conda
self._no_check = no_check or IS_IN_STORED_PROC or SKIP_SQL_COUNT_CHECK

# Save any expected sql counts initialized at start up.
self._expected_sql_counts = {}
Expand Down Expand Up @@ -357,12 +363,6 @@ def sql_count_checker(
*args,
**kwargs,
):
# Bypassing sql counter since
# 1. it is an unnecessary metric for tests running in stored procedures
# 2. pytest-assume package is not available in conda
if IS_IN_STORED_PROC:
return

"""SqlCounter decorator that automatically validates the sql counts when test finishes."""
sql_counter = SqlCounter(
no_check=no_check,
Expand Down

0 comments on commit e7813c1

Please sign in to comment.