Skip to content

Conversation

@philion
Copy link
Member

@philion philion commented Feb 19, 2025

Migrating python to the latest v3.13, and updating all the packages. All test cases working.

The specific problem, that required a lot of experimentation, was a non-mocked method that should have been auto-mocked with an AsyncMock, but got a MagicMock instead:

    def mock_context(self) -> ApplicationContext:
        ctx = mock.AsyncMock(ApplicationContext)
        ctx.bot = mock.AsyncMock(NetBot)
        ctx.bot.redmine = self.redmine
        ctx.user = mock.AsyncMock(discord.Member)
        ctx.user.name = self.user.discord_id.name
        ctx.user.id = self.user.discord_id.id

        ctx.respond = mock.AsyncMock()

        return ctx

ctx.respond = was the solution, essentially pre-populating that method call with an AsyncMock.

@philion philion self-assigned this Feb 19, 2025
@philion
Copy link
Member Author

philion commented Feb 19, 2025

Note to Esther and Rudra: Don't really need a review. Just wanted to share to fix.

@infrared0 infrared0 merged commit d086f5d into main Feb 19, 2025
1 check passed
@philion philion deleted the py313 branch February 19, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants