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

Rename: ActivationResult.get_failure_text() #270

Merged
merged 1 commit into from
Apr 23, 2024
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: 1 addition & 1 deletion src/wakepy/core/activationresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def query(

return out

def get_error_text(self) -> str:
def get_failure_text(self) -> str:
"""Gets information about a failure as text. In case the mode
activation was successful, returns an empty string."""

Expand Down
4 changes: 2 additions & 2 deletions src/wakepy/core/mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@ def handle_activation_fail(on_fail: OnFail, result: ActivationResult) -> None:
if on_fail == "pass":
return
elif on_fail == "warn":
warnings.warn(result.get_error_text())
warnings.warn(result.get_failure_text())
return
elif on_fail == "error":
raise ActivationError(result.get_error_text())
raise ActivationError(result.get_failure_text())
elif not callable(on_fail):
raise ValueError(
'on_fail must be one of "error", "warn", pass" or a callable which takes '
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_core/test_activationresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,22 +288,22 @@ def test_activation_result_success(
assert ar.real_success == real_success_expected
assert ar.failure == (not success_expected)

def test_get_error_text_success(
def test_get_failure_text_success(
self, method_activation_results1: List[MethodActivationResult]
):
ar = ActivationResult(method_activation_results1)
# error text is empty string in case of success.
assert ar.get_error_text() == ""
assert ar.get_failure_text() == ""

def test_get_error_text_failure(
def test_get_failure_text_failure(
self,
mr_platform_support_fail: MethodActivationResult,
mr_requirements_fail: MethodActivationResult,
):
ar = ActivationResult(
[mr_platform_support_fail, mr_requirements_fail], modename="SomeMode"
)
assert ar.get_error_text() == (
assert ar.get_failure_text() == (
'Could not activate Mode "SomeMode"!\n\nMethod usage results, in order '
"(highest priority first):\n[(FAIL @PLATFORM_SUPPORT, fail-platform, "
'"Platform XYZ not supported!"), (FAIL @REQUIREMENTS, fail-requirements, '
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_core/test_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def result1():
@staticmethod
@pytest.fixture
def error_text_match(result1):
return re.escape(result1.get_error_text())
return re.escape(result1.get_failure_text())

def test_pass(self, result1):
with warnings.catch_warnings():
Expand Down