This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_long_future is faulty
Type: behavior Stage: patch review
Components: Tests Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, flox, mark.dickinson
Priority: low Keywords: patch

Created on 2009-12-20 18:26 by flox, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7553_test_long_future.diff flox, 2009-12-20 18:29 Patch, apply to trunk
Messages (6)
msg96710 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-20 18:26
This test do not test "true division" contrary to what is claimed.

    for zero in ["huge / 0", "huge / 0L", "mhuge / 0", "mhuge / 0L"]:
        self.assertRaises(ZeroDivisionError, eval, zero, namespace)

Because it uses the module "unittest" to eval the expression.
And __future__.division is not active in unittest module.

Other tests were OK.
msg96711 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-20 18:29
Patch which fixes the tests: call the "eval" in the module.
msg96714 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-20 18:46
Removed 2.6 from the todolist. Not worth the effort.

"with self.assertRaises(...):" construct is not supported in 2.6.
msg96715 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-12-20 18:50
eval() inherits the flags of the module it is used in.
msg96716 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-20 19:01
Let me show the issue:

~ $ cat bar.py
def apply_(func, args=(), kw={}):
    return func(*args, **kw)

~ $ cat foo.py
from __future__ import division
import bar

def test():
    assert eval('1/2') == .5
    assert apply(eval, ('1/2',)) == .5

    # This test yield AssertionError
    assert bar.apply_(eval, ('1/2',)) == .5

test()

~ $ ./python foo.py
Traceback (most recent call last):
  File "foo.py", line 11, in <module>
    test()
  File "foo.py", line 9, in test
    assert bar.apply_(eval, ('1/2',)) == .5
AssertionError


Then replace "foo.py" by "test_long_future.py"
and "bar.py" by "Lib/unittest/case.py" ...
msg96759 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-12-21 16:31
Applied in r76984.  Thanks!
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51802
2009-12-21 16:31:21mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg96759

resolution: fixed
2009-12-20 19:01:29floxsetstatus: closed -> open
resolution: works for me -> (no value)
messages: + msg96716
2009-12-20 18:50:37benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg96715

resolution: works for me
2009-12-20 18:46:07floxsetmessages: + msg96714
versions: - Python 2.6
2009-12-20 18:34:25floxsetstage: patch review
2009-12-20 18:29:20floxsetfiles: + issue7553_test_long_future.diff
keywords: + patch
messages: + msg96711
2009-12-20 18:26:58floxcreate