Skip to content

Commit f78922e

Browse files
felixwang9817kevjumba
authored andcommitted
chore: Change pytest fixtures to be function-scoped instead of session-scoped (#2899)
* Test to trigger registry conflicts Signed-off-by: Felix Wang <[email protected]> * Switch environment and associated fixtures to being function scoped Signed-off-by: Felix Wang <[email protected]> * Format Signed-off-by: Felix Wang <[email protected]> * Switch type tests to function-scoped fixtures Signed-off-by: Felix Wang <[email protected]> * Format Signed-off-by: Felix Wang <[email protected]>
1 parent 895c2e4 commit f78922e

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

sdk/python/tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def start_test_local_server(repo_path: str, port: int):
161161
fs.serve("localhost", port, no_access_log=True)
162162

163163

164-
@pytest.fixture(scope="session")
164+
@pytest.fixture
165165
def environment(request, worker_id):
166166
e = construct_test_environment(
167167
request.param, worker_id=worker_id, fixture_request=request
@@ -293,7 +293,7 @@ def pytest_generate_tests(metafunc: pytest.Metafunc):
293293
)
294294

295295

296-
@pytest.fixture(scope="session")
296+
@pytest.fixture
297297
def feature_server_endpoint(environment):
298298
if (
299299
not environment.python_feature_server
@@ -344,12 +344,12 @@ def _free_port():
344344
return sock.getsockname()[1]
345345

346346

347-
@pytest.fixture(scope="session")
347+
@pytest.fixture
348348
def universal_data_sources(environment) -> TestData:
349349
return construct_universal_test_data(environment)
350350

351351

352-
@pytest.fixture(scope="session")
352+
@pytest.fixture
353353
def e2e_data_sources(environment: Environment):
354354
df = create_dataset()
355355
data_source = environment.data_source_creator.create_data_source(

sdk/python/tests/integration/e2e/test_go_feature_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
)
3636

3737

38-
@pytest.fixture(scope="session")
38+
@pytest.fixture
3939
def initialized_registry(environment, universal_data_sources):
4040
fs = environment.feature_store
4141

sdk/python/tests/integration/registration/test_universal_types.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ class TypeTestConfig:
6464

6565

6666
@pytest.fixture(
67-
params=OFFLINE_TYPE_TEST_CONFIGS,
68-
scope="session",
69-
ids=[str(c) for c in OFFLINE_TYPE_TEST_CONFIGS],
67+
params=OFFLINE_TYPE_TEST_CONFIGS, ids=[str(c) for c in OFFLINE_TYPE_TEST_CONFIGS],
7068
)
7169
def offline_types_test_fixtures(request, environment):
7270
config: TypeTestConfig = request.param
@@ -80,9 +78,7 @@ def offline_types_test_fixtures(request, environment):
8078

8179

8280
@pytest.fixture(
83-
params=ONLINE_TYPE_TEST_CONFIGS,
84-
scope="session",
85-
ids=[str(c) for c in ONLINE_TYPE_TEST_CONFIGS],
81+
params=ONLINE_TYPE_TEST_CONFIGS, ids=[str(c) for c in ONLINE_TYPE_TEST_CONFIGS],
8682
)
8783
def online_types_test_fixtures(request, environment):
8884
return get_fixtures(request, environment)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
3+
from feast.entity import Entity
4+
5+
6+
@pytest.mark.integration
7+
def test_apply_first_entity(environment):
8+
entity = Entity(name="first")
9+
fs = environment.feature_store
10+
fs.apply([entity])
11+
12+
entities = fs.list_entities()
13+
assert len(entities) == 1
14+
15+
16+
@pytest.mark.integration
17+
def test_apply_second_entity(environment):
18+
entity = Entity(name="second")
19+
fs = environment.feature_store
20+
fs.apply([entity])
21+
22+
entities = fs.list_entities()
23+
assert len(entities) == 1

0 commit comments

Comments
 (0)