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

[🐞 Bug]: Fix test_mock_abstract_enum_is_abstract #327

Closed
2 tasks done
SZeltaat opened this issue Jul 31, 2024 · 0 comments · Fixed by #332
Closed
2 tasks done

[🐞 Bug]: Fix test_mock_abstract_enum_is_abstract #327

SZeltaat opened this issue Jul 31, 2024 · 0 comments · Fixed by #332
Assignees
Labels
bug Something isn't working

Comments

@SZeltaat
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Blueprints.

Issue description

test_mock_abstract_enum_is_abstract catches a TypeError, but the wrong one.
Fix:

class MockAbstractEnumWithMembers(Enum, metaclass=ABCEnumMeta):
    """Mock class with members for testing the ABCEnumMeta class."""

    A = "a"

    @abstractmethod
    def test_method(self) -> int:
        """Test method for the MockAbstractEnum class."""
    def test_mock_abstract_enum_is_abstract(self) -> None:
        """Test case for MockAbstractEnum class to check if it's an abstract class."""
        assert MockAbstractEnum.__abstractmethods__ == frozenset({"test_method"})
        with pytest.raises(TypeError) as error_info:
            _ = MockAbstractEnumWithMembers("a")  # type: ignore[abstract]
        assert str(error_info.value) == "Can't instantiate abstract class 'MockAbstractEnumWithMembers' without an implementation for abstract method 'test_method'"

Reproducible example

The last assert would show that the TypeError in current implementation of the test is not the right one.

    def test_mock_abstract_enum_is_abstract(self) -> None:
        """Test case for MockAbstractEnum class to check if it's an abstract class."""
        assert MockAbstractEnum.__abstractmethods__ == frozenset({"test_method"})
        with pytest.raises(TypeError) as error_info:
            _ = MockAbstractEnumWithMembers("a")  # type: ignore[abstract]
        assert str(error_info.value) == "Can't instantiate abstract class 'MockAbstractEnumWithMembers' without an implementation for abstract method 'test_method'"

Expected behavior

wrong test

Installed versions

latest
@SZeltaat SZeltaat added the bug Something isn't working label Jul 31, 2024
@SZeltaat SZeltaat self-assigned this Jul 31, 2024
@SZeltaat SZeltaat linked a pull request Aug 1, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant