From 25d1ba522f9d7ca6f1a762ec532e528a49c79eaf Mon Sep 17 00:00:00 2001 From: Han Wang Date: Fri, 24 Nov 2023 07:35:44 +0000 Subject: [PATCH] update --- fugue/test/__init__.py | 2 +- .../test/{pandas_backend.py => pandas_tester.py} | 0 fugue/test/plugins.py | 7 +++---- fugue_test/__init__.py | 15 +++++++++++++-- setup.py | 2 +- tests/fugue/test/test_plugins.py | 11 +++++++---- 6 files changed, 25 insertions(+), 12 deletions(-) rename fugue/test/{pandas_backend.py => pandas_tester.py} (100%) diff --git a/fugue/test/__init__.py b/fugue/test/__init__.py index 8e361de5..7fbc9a3f 100644 --- a/fugue/test/__init__.py +++ b/fugue/test/__init__.py @@ -1,5 +1,5 @@ # flake8: noqa -from .pandas_backend import NativeTestBackend, PandasTestBackend +from .pandas_tester import NativeTestBackend, PandasTestBackend from .plugins import ( FugueTestBackend, FugueTestContext, diff --git a/fugue/test/pandas_backend.py b/fugue/test/pandas_tester.py similarity index 100% rename from fugue/test/pandas_backend.py rename to fugue/test/pandas_tester.py diff --git a/fugue/test/plugins.py b/fugue/test/plugins.py index dcaa887b..5ccc144d 100644 --- a/fugue/test/plugins.py +++ b/fugue/test/plugins.py @@ -17,7 +17,6 @@ _FUGUE_TEST_BACKENDS: Dict[str, Type["FugueTestBackend"]] = {} _FUGUE_TEST_ALL_INI_CONF: Dict[str, Any] = {} _FUGUE_TEST_INI_FUGUE_CONF: Dict[str, Any] = {} -_FUGUE_BACKEND_SESSION_FIXTURES: Dict[str, Any] = {} def _set_global_conf(conf: Dict[str, Any]) -> None: @@ -30,8 +29,8 @@ def _get_all_ini_conf() -> Dict[str, Any]: return _FUGUE_TEST_ALL_INI_CONF -def _get_all_backend_session_fixtures() -> Dict[str, Any]: - return _FUGUE_BACKEND_SESSION_FIXTURES +def _get_all_backends() -> Dict[str, Type["FugueTestBackend"]]: + return _FUGUE_TEST_BACKENDS def _load_all_backends() -> None: @@ -40,7 +39,7 @@ def _load_all_backends() -> None: load_entry_point(FUGUE_ENTRYPOINT) -def with_backend(ctx: str, *other: str, skip_missing: bool = False) -> Any: +def with_backend(ctx: Any, *other: Any, skip_missing: bool = False) -> Any: import pytest _load_all_backends() diff --git a/fugue_test/__init__.py b/fugue_test/__init__.py index 8020a09a..bce42f42 100644 --- a/fugue_test/__init__.py +++ b/fugue_test/__init__.py @@ -77,11 +77,22 @@ def tmp_mem_dir(): pass +@pytest.fixture(scope="session") +def pandas_session(): + yield "pandas" + + +@pytest.fixture(scope="session") +def native_session(): + yield "native" + + @pytest.fixture(scope="class") def backend_context(request: Any): - from fugue.test.plugins import _make_backend_context + from fugue.test.plugins import _make_backend_context, _parse_backend - session = request.getfixturevalue(request.param[0] + "_session") + c, _ = _parse_backend(request.param) + session = request.getfixturevalue(c + "_session") with _make_backend_context(request.param, session) as ctx: yield ctx diff --git a/setup.py b/setup.py index 8d607944..f9ee2c91 100644 --- a/setup.py +++ b/setup.py @@ -109,7 +109,7 @@ def get_version() -> str: ], "pytest11": [ "fugue_test = fugue_test", - "fugue_test_spark = fugue_spark.tester", + # "fugue_test_spark = fugue_spark.tester", # "fugue_test_duckdb = fugue_duckdb.test_backend" # "fugue_test_plugins = fugue.test.plugins", # "fugue_test_fixtures = fugue.test.fixtures", diff --git a/tests/fugue/test/test_plugins.py b/tests/fugue/test/test_plugins.py index ee2bcb7c..d50c9686 100644 --- a/tests/fugue/test/test_plugins.py +++ b/tests/fugue/test/test_plugins.py @@ -3,16 +3,14 @@ import pytest -import fugue.test as ft import fugue.api as fa +import fugue.test as ft from fugue import NativeExecutionEngine - -from fugue.test.pandas_backend import PandasTestBackend from fugue_test import _parse_line @ft.fugue_test_backend -class _MockPandasTestBackend(PandasTestBackend): +class _MockPandasTestBackend(ft.FugueTestBackend): name = "pandas_test_test" default_session_conf = {"a": 1, "aa": 2} default_fugue_conf = {"fugue.b": 2} @@ -26,6 +24,11 @@ def session_context(cls, session_conf: Dict[str, Any]) -> Iterator[Any]: yield "pandas" +@pytest.fixture(scope="session") +def pandas_test_test_session(): + yield "pandas" + + @pytest.fixture(scope="session") def f_dummy(): return 1