From 7598c4b855358115895051273acfdf3e1077878c Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 21 Oct 2024 11:20:54 -0700 Subject: [PATCH] Rename `patch_id_generators` to `setup_id_generators`. --- .../metricflow_semantics/test_helpers/id_helpers.py | 6 ++++-- metricflow-semantics/tests_metricflow_semantics/conftest.py | 2 +- tests_metricflow/conftest.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py b/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py index d54e57b052..7a55987031 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py +++ b/metricflow-semantics/metricflow_semantics/test_helpers/id_helpers.py @@ -9,11 +9,13 @@ @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. +def setup_id_generators() -> Generator[None, None, None]: + """Setup ID generation to start numbering at a specific value to get repeatability in generated IDs. 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. + + Fixtures may generate IDs, so this needs to be done before every test. """ with SequentialIdGenerator.id_number_space(start_value=IdNumberSpace.for_test_start().start_value): yield None diff --git a/metricflow-semantics/tests_metricflow_semantics/conftest.py b/metricflow-semantics/tests_metricflow_semantics/conftest.py index 89da8c19db..b7e51ebb1d 100644 --- a/metricflow-semantics/tests_metricflow_semantics/conftest.py +++ b/metricflow-semantics/tests_metricflow_semantics/conftest.py @@ -1,7 +1,7 @@ # 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 metricflow_semantics.test_helpers.id_helpers import setup_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/tests_metricflow/conftest.py b/tests_metricflow/conftest.py index ef0cd5cd18..a593968adc 100644 --- a/tests_metricflow/conftest.py +++ b/tests_metricflow/conftest.py @@ -1,7 +1,7 @@ # 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 metricflow_semantics.test_helpers.id_helpers import setup_id_generators # noqa: F401 from tests_metricflow.fixtures.cli_fixtures import * # noqa: F401, F403 from tests_metricflow.fixtures.dataflow_fixtures import * # noqa: F401, F403