|
|
@ -234,10 +234,9 @@ def test_beta_property() -> None:
|
|
|
|
assert doc.startswith("[*Beta*] original doc")
|
|
|
|
assert doc.startswith("[*Beta*] original doc")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_whole_class_deprecation() -> None:
|
|
|
|
def test_whole_class_beta() -> None:
|
|
|
|
"""Test whole class deprecation."""
|
|
|
|
"""Test whole class beta status."""
|
|
|
|
|
|
|
|
|
|
|
|
# Test whole class deprecation
|
|
|
|
|
|
|
|
@beta()
|
|
|
|
@beta()
|
|
|
|
class BetaClass:
|
|
|
|
class BetaClass:
|
|
|
|
def __init__(self) -> None:
|
|
|
|
def __init__(self) -> None:
|
|
|
@ -269,6 +268,73 @@ def test_whole_class_deprecation() -> None:
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_whole_class_inherited_beta() -> None:
|
|
|
|
|
|
|
|
"""Test whole class beta status for inherited class.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The original version of beta decorator created duplicates with
|
|
|
|
|
|
|
|
'[*Beta*]'.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Test whole class beta status
|
|
|
|
|
|
|
|
@beta()
|
|
|
|
|
|
|
|
class BetaClass:
|
|
|
|
|
|
|
|
@beta()
|
|
|
|
|
|
|
|
def beta_method(self) -> str:
|
|
|
|
|
|
|
|
"""original doc"""
|
|
|
|
|
|
|
|
return "This is a beta method."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@beta()
|
|
|
|
|
|
|
|
class InheritedBetaClass(BetaClass):
|
|
|
|
|
|
|
|
@beta()
|
|
|
|
|
|
|
|
def beta_method(self) -> str:
|
|
|
|
|
|
|
|
"""original doc"""
|
|
|
|
|
|
|
|
return "This is a beta method 2."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with warnings.catch_warnings(record=True) as warning_list:
|
|
|
|
|
|
|
|
warnings.simplefilter("always")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj = BetaClass()
|
|
|
|
|
|
|
|
assert obj.beta_method() == "This is a beta method."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert len(warning_list) == 2
|
|
|
|
|
|
|
|
warning = warning_list[0].message
|
|
|
|
|
|
|
|
assert str(warning) == (
|
|
|
|
|
|
|
|
"The class `BetaClass` is in beta. It is actively being worked on, so the "
|
|
|
|
|
|
|
|
"API may change."
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
warning = warning_list[1].message
|
|
|
|
|
|
|
|
assert str(warning) == (
|
|
|
|
|
|
|
|
"The function `beta_method` is in beta. It is actively being worked on, so "
|
|
|
|
|
|
|
|
"the API may change."
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with warnings.catch_warnings(record=True) as warning_list:
|
|
|
|
|
|
|
|
warnings.simplefilter("always")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj = InheritedBetaClass()
|
|
|
|
|
|
|
|
assert obj.beta_method() == "This is a beta method 2."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert len(warning_list) == 2
|
|
|
|
|
|
|
|
warning = warning_list[0].message
|
|
|
|
|
|
|
|
assert str(warning) == (
|
|
|
|
|
|
|
|
"The class `InheritedBetaClass` is in beta. "
|
|
|
|
|
|
|
|
"It is actively being worked on, so the "
|
|
|
|
|
|
|
|
"API may change."
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
warning = warning_list[1].message
|
|
|
|
|
|
|
|
assert str(warning) == (
|
|
|
|
|
|
|
|
"The function `beta_method` is in beta. "
|
|
|
|
|
|
|
|
"It is actively being worked on, so "
|
|
|
|
|
|
|
|
"the API may change."
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if [*Beta*] was inserted only once:
|
|
|
|
|
|
|
|
if obj.__doc__ is not None:
|
|
|
|
|
|
|
|
assert obj.__doc__.count("[*Beta*]") == 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Tests with pydantic models
|
|
|
|
# Tests with pydantic models
|
|
|
|
class MyModel(BaseModel):
|
|
|
|
class MyModel(BaseModel):
|
|
|
|
@beta()
|
|
|
|
@beta()
|
|
|
|