Skip to content

Approx repr ugly with complex numbers #2082

@adler-j

Description

@adler-j

MWE:

def test_complex():
    assert pytest.approx(1j) == 2j

Result:


=================================== FAILURES ===================================
_________________________________ test_complex _________________________________

>   ???
E   assert <[TypeError("can't convert complex to float") raised in repr()] SafeRepr object at 0x7f40613577a0> == 2j
E    +  where <[TypeError("can't convert complex to float") raised in repr()] SafeRepr object at 0x7f40613577a0> = <class '_pytest.python.approx'>(1j)
E    +    where <class '_pytest.python.approx'> = pytest.approx

This should clearly be fixed.

Version:

>>> pytest.__version__
'3.0.3'

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorstatus: help wanteddevelopers would like help from experts on this topictype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions