Skip to content

Commit 6047892

Browse files
authored
TEST-modin-project#5008: Set benchmark mode within unit test instead of with environment variable (modin-project#6359)
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
1 parent a921b7b commit 6047892

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ jobs:
350350
run: |
351351
sudo docker pull postgres
352352
sudo docker run --name some-postgres -e POSTGRES_USER=sa -e POSTGRES_PASSWORD=Strong.Pwd-123 -e POSTGRES_DB=postgres -d -p 2345:5432 postgres
353-
- run: MODIN_BENCHMARK_MODE=True mpiexec -n 1 python -m pytest modin/pandas/test/internals/test_benchmark_mode.py
353+
- run: mpiexec -n 1 python -m pytest modin/pandas/test/internals/test_benchmark_mode.py
354354
- run: mpiexec -n 1 python -m pytest modin/pandas/test/internals/test_repartition.py
355355
- run: mpiexec -n 1 python -m pytest modin/test/test_partition_api.py
356356
- uses: ./.github/actions/run-core-tests
@@ -447,7 +447,7 @@ jobs:
447447
sudo docker run --name some-postgres -e POSTGRES_USER=sa -e POSTGRES_PASSWORD=Strong.Pwd-123 -e POSTGRES_DB=postgres -d -p 2345:5432 postgres
448448
if: matrix.os == 'ubuntu'
449449

450-
- run: MODIN_BENCHMARK_MODE=True python -m pytest modin/pandas/test/internals/test_benchmark_mode.py
450+
- run: python -m pytest modin/pandas/test/internals/test_benchmark_mode.py
451451
if: matrix.engine == 'python' || matrix.test_task == 'group_1'
452452
- run: python -m pytest modin/pandas/test/internals/test_repartition.py
453453
if: matrix.engine == 'python' || matrix.test_task == 'group_1'

modin/conftest.py

+9
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _saving_make_api_url(token, _make_api_url=modin.utils._make_api_url):
6262
CIAWSAccessKeyID,
6363
CIAWSSecretAccessKey,
6464
AsyncReadMode,
65+
BenchmarkMode,
6566
)
6667
import uuid # noqa: E402
6768

@@ -558,6 +559,14 @@ def set_num_partitions(request):
558559
NPartitions.put(old_num_partitions)
559560

560561

562+
@pytest.fixture()
563+
def set_benchmark_mode(request):
564+
old_benchmark_mode = BenchmarkMode.get()
565+
BenchmarkMode.put(request.param)
566+
yield
567+
BenchmarkMode.put(old_benchmark_mode)
568+
569+
561570
@pytest.fixture
562571
def set_async_read_mode(request):
563572
old_async_read_mode = AsyncReadMode.get()

modin/pandas/test/internals/test_benchmark_mode.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
import unittest.mock as mock
1515

16+
import pytest
17+
1618
import modin.pandas as pd
17-
from modin.pandas.test.utils import test_data_values
18-
from modin.config import BenchmarkMode, Engine
19+
from modin.config import Engine
1920

2021

2122
engine = Engine.get()
@@ -46,26 +47,17 @@
4647
)
4748

4849

49-
def test_from_environment_variable():
50-
assert BenchmarkMode.get()
51-
with mock.patch(wait_method) as wait:
52-
pd.DataFrame(test_data_values[0]).mean()
53-
54-
wait.assert_called()
55-
56-
57-
def test_turn_off():
50+
@pytest.mark.parametrize("set_benchmark_mode", [False], indirect=True)
51+
def test_turn_off(set_benchmark_mode):
5852
df = pd.DataFrame([0])
59-
BenchmarkMode.put(False)
6053
with mock.patch(wait_method) as wait:
6154
df.dropna()
6255
wait.assert_not_called()
6356

6457

65-
def test_turn_on():
66-
BenchmarkMode.put(False)
58+
@pytest.mark.parametrize("set_benchmark_mode", [True], indirect=True)
59+
def test_turn_on(set_benchmark_mode):
6760
df = pd.DataFrame([0])
68-
BenchmarkMode.put(True)
6961
with mock.patch(wait_method) as wait:
7062
df.dropna()
7163
wait.assert_called()

0 commit comments

Comments
 (0)