Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add deprecation warning when importing legacy testing helpers #1838

Merged
merged 13 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/deprecation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ incompatible way, following their deprecation, as indicated in the
[`RESTStream.get_new_paginator`](singer_sdk.RESTStream.get_new_paginator).

See the [migration guide](./guides/pagination-classes.md) for more information.

- The `singer_sdk.testing.get_standard_tap_tests` and `singer_sdk.testing.get_standard_target_tests` functions will be removed. Replace them with `singer_sdk.testing.get_tap_test_class` and `singer_sdk.testing.get_target_test_class` functions respective to generate a richer test suite.
38 changes: 34 additions & 4 deletions singer_sdk/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,57 @@

from __future__ import annotations

import typing as t
import warnings

from .config import SuiteConfig
from .factory import get_tap_test_class, get_target_test_class
from .legacy import (
_get_tap_catalog,
_select_all,
get_standard_tap_tests,
get_standard_target_tests,
sync_end_to_end,
tap_sync_test,
tap_to_target_sync_test,
target_sync_test,
)
from .runners import SingerTestRunner, TapTestRunner, TargetTestRunner


def __getattr__(name: str) -> t.Any: # noqa: ANN401
if name == "get_standard_tap_tests":
warnings.warn(
"The function singer_sdk.testing.get_standard_tap_tests is deprecated "
"and will be removed in a future release. Use get_tap_test_class instead.",
DeprecationWarning,
stacklevel=2,
)

from .legacy import get_standard_tap_tests

return get_standard_tap_tests

if name == "get_standard_target_tests":
warnings.warn(
"The function singer_sdk.testing.get_standard_target_tests is deprecated "
"and will be removed in a future release. Use get_target_test_class "
"instead.",
DeprecationWarning,
stacklevel=2,
)

from .legacy import get_standard_target_tests

return get_standard_target_tests

msg = f"module {__name__} has no attribute {name}"
raise AttributeError(msg)


__all__ = [
"get_tap_test_class",
"get_target_test_class",
"_get_tap_catalog",
"_select_all",
"get_standard_tap_tests",
"get_standard_target_tests",
"sync_end_to_end",
"tap_sync_test",
"tap_to_target_sync_test",
Expand Down
21 changes: 21 additions & 0 deletions tests/core/test_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Test the plugin testing helpers."""

from __future__ import annotations

import pytest


def test_module_deprecations():
with pytest.deprecated_call():
from singer_sdk.testing import get_standard_tap_tests # noqa: F401

with pytest.deprecated_call():
from singer_sdk.testing import get_standard_target_tests # noqa: F401

from singer_sdk import testing

with pytest.raises(
AttributeError,
match="module singer_sdk.testing has no attribute",
):
testing.foo # noqa: B018