Skip to content

monkeypatch'ing functools.partial causes INTERNALERROR #3288

@JoseKilo

Description

@JoseKilo

Hi,

I've got this test

import functools
from unittest.mock import Mock


def test_partial(monkeypatch):
    monkeypatch.setattr(functools, "partial", Mock())
    assert functools.partial.call_count == 1

Running pytest on a clean environment produces:

INTERNALERROR>     if isinstance(obj, functools.partial):
INTERNALERROR> TypeError: isinstance() arg 2 must be a type or tuple of types

I'm not sure if this kind of patching is supported.
Note that the error only happens if the assert causes the test to fail, otherwise everything works.

I'm using version 3.4.2

pip list:

attrs (17.4.0)
pip (9.0.1)
pkg-resources (0.0.0)
pluggy (0.6.0)
py (1.5.2)
pytest (3.4.2)
setuptools (38.5.2)
six (1.11.0)
wheel (0.30.0)

OS: Ubuntu 16.04.4 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: monkeypatchrelated to the monkeypatch builtin plugintype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions