Skip to content

unittest.mock.patch does not work on WASM build #96630

Closed
@treyhunner

Description

@treyhunner

Bug report

When importing unittest.mock, an exception is raised due to unittest.mock importing asyncio.

It seems the asyncio library is only used in unittest.mock when mocking async functions.

I believe delaying the import of asyncio until the moment it's needed would make unittest.mock functional for most use cases on WASM builds.

A demonstration of the error: https://www.pythonmorsels.com/r/35fv2/

Your environment

CPython 3.11.0rc1 built with Emscripten for the web browser

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesOS-wasistdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions