diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py b/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py index 083cbb1a1d..1a3a3c3a94 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py +++ b/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py @@ -5,6 +5,8 @@ from typing import Generator from unittest.mock import patch +import pytest + from metricflow_semantics.dag.sequential_id import SequentialIdGenerator @@ -28,6 +30,17 @@ def patch_id_generators_helper(start_value: int) -> Generator[None, None, None]: yield None +@pytest.fixture(autouse=True, scope="function") +def patch_id_generators() -> Generator[None, None, None]: + """Patch ID generators with a new one to get repeatability in plan outputs before every test. + + Plan outputs contain IDs, so if the IDs are not consistent from run to run, there will be diffs in the actual vs. + expected outputs during a test. + """ + with patch_id_generators_helper(start_value=IdNumberSpace.for_test_start().start_value): + yield None + + @dataclass(frozen=True) class IdNumberSpace: """Defines the numbering of IDs when setting up tests and test fixtures.""" diff --git a/metricflow-semantics/tests_metricflow_semantics/conftest.py b/metricflow-semantics/tests_metricflow_semantics/conftest.py index 1adfb60cd8..89da8c19db 100644 --- a/metricflow-semantics/tests_metricflow_semantics/conftest.py +++ b/metricflow-semantics/tests_metricflow_semantics/conftest.py @@ -1,6 +1,7 @@ # These imports are required to properly set up pytest fixtures. from __future__ import annotations -from tests_metricflow_semantics.fixtures.id_fixtures import * # noqa: F401, F403 +from metricflow_semantics.test_helpers.id_helpers import patch_id_generators # noqa: F401 + from tests_metricflow_semantics.fixtures.manifest_fixtures import * # noqa: F401, F403 from tests_metricflow_semantics.fixtures.setup_fixtures import * # noqa: F401, F403 diff --git a/metricflow-semantics/tests_metricflow_semantics/fixtures/id_fixtures.py b/metricflow-semantics/tests_metricflow_semantics/fixtures/id_fixtures.py deleted file mode 100644 index cec3c0131a..0000000000 --- a/metricflow-semantics/tests_metricflow_semantics/fixtures/id_fixtures.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import annotations - -from typing import Generator - -import pytest -from metricflow_semantics.test_helpers.id_helpers import IdNumberSpace, patch_id_generators_helper - - -@pytest.fixture(autouse=True, scope="function") -def patch_id_generators() -> Generator[None, None, None]: - """Patch ID generators with a new one to get repeatability in plan outputs before every test. - - Plan outputs contain IDs, so if the IDs are not consistent from run to run, there will be diffs in the actual vs. - expected outputs during a test. - """ - with patch_id_generators_helper(start_value=IdNumberSpace.for_test_start().start_value): - yield None diff --git a/tests_metricflow/conftest.py b/tests_metricflow/conftest.py index 46f268c40f..ef0cd5cd18 100644 --- a/tests_metricflow/conftest.py +++ b/tests_metricflow/conftest.py @@ -1,9 +1,10 @@ # These imports are required to properly set up pytest fixtures. from __future__ import annotations +from metricflow_semantics.test_helpers.id_helpers import patch_id_generators # noqa: F401 + from tests_metricflow.fixtures.cli_fixtures import * # noqa: F401, F403 from tests_metricflow.fixtures.dataflow_fixtures import * # noqa: F401, F403 -from tests_metricflow.fixtures.id_fixtures import * # noqa: F401, F403 from tests_metricflow.fixtures.manifest_fixtures import * # noqa: F401, F403 from tests_metricflow.fixtures.setup_fixtures import * # noqa: F401, F403 from tests_metricflow.fixtures.sql_client_fixtures import * # noqa: F401, F403 diff --git a/tests_metricflow/fixtures/id_fixtures.py b/tests_metricflow/fixtures/id_fixtures.py deleted file mode 100644 index cec3c0131a..0000000000 --- a/tests_metricflow/fixtures/id_fixtures.py +++ /dev/null @@ -1,17 +0,0 @@ -from __future__ import annotations - -from typing import Generator - -import pytest -from metricflow_semantics.test_helpers.id_helpers import IdNumberSpace, patch_id_generators_helper - - -@pytest.fixture(autouse=True, scope="function") -def patch_id_generators() -> Generator[None, None, None]: - """Patch ID generators with a new one to get repeatability in plan outputs before every test. - - Plan outputs contain IDs, so if the IDs are not consistent from run to run, there will be diffs in the actual vs. - expected outputs during a test. - """ - with patch_id_generators_helper(start_value=IdNumberSpace.for_test_start().start_value): - yield None