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

Possible bug in pytest --doctest comparison #2796

Closed
mirca opened this issue Sep 24, 2017 · 5 comments
Closed

Possible bug in pytest --doctest comparison #2796

mirca opened this issue Sep 24, 2017 · 5 comments
Labels
plugin: doctests related to the doctests builtin plugin status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: bug problem that needs to be addressed

Comments

@mirca
Copy link

mirca commented Sep 24, 2017

In Python:

>>> -0.0 == 0.0
True

Whereas while running pytest --doctest-modules (version 3.0.7):

Expected:
    0.0
Got:
    -0.0
@nicoddemus
Copy link
Member

Thanks @mirca.

I can't reproduce the problem though, either on master or in version 3.0.7. Could you please test using the latest version and provide a minimal reproducible example if the error still happens? Thanks!

@nicoddemus nicoddemus added plugin: doctests related to the doctests builtin plugin status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: bug problem that needs to be addressed labels Sep 25, 2017
@mirca
Copy link
Author

mirca commented Sep 26, 2017

I tested with version 3.2.1 as well and got the same error:

➜ pytest --doctest-modules test.py
================================= test session starts ==================================
platform darwin -- Python 3.6.2, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
rootdir: /Users/jvmirca, inifile:
plugins: pep8-1.0.6, cov-2.5.1
collected 1 item

test.py F

======================================= FAILURES =======================================
____________________________________ [doctest] test ____________________________________
001
002 >>> import numpy as np
003 >>> - np.log(1)
Expected:
    0.0
Got:
    -0.0

where test.py is:

"""
>>> import numpy as np
>>> - np.log(1)
0.0
"""

@nicoddemus
Copy link
Member

Thanks @mirca for the reproducible example.

I can reproduce the same error in pytest and also using the standard library's doctest:

"""
>>> import numpy as np
>>> - np.log(1)
0.0
"""

if __name__ == '__main__':
    import doctest
    doctest.testmod()
$python .tmp\test_doctest.py
**********************************************************************
File ".tmp\test_doctest.py", line 3, in __main__
Failed example:
    - np.log(1)
Expected:
    0.0
Got:
    -0.0
**********************************************************************
1 items had failures:
   1 of   2 in __main__
***Test Failed*** 1 failures.

pytest uses the standard doctest for test collection and comparison, so it is actually a bug in python's doctest module. I suggest to report this problem in Python's issue tracker.

pytest can't really do anything in this case, so I'm closing this.

@mirca
Copy link
Author

mirca commented Sep 26, 2017

@nicoddemus Thanks for following up on this.

@nicoddemus
Copy link
Member

No problem 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: doctests related to the doctests builtin plugin status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants