classification
Title: test_statistics fails in refleak mode
Type: behavior Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder: test_asyncio unstable in refleak mode
View: 22104
Assigned To: steven.daprano Nosy List: ezio.melotti, pitrou, steven.daprano, xdegaye, zach.ware
Priority: high Keywords:

Created on 2014-02-23 17:17 by pitrou, last changed 2014-08-29 05:42 by zach.ware. This issue is now closed.

Messages (7)
msg212008 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-02-23 17:17
$ ./python -m test -W -R3:3 test_statistics
[1/1] test_statistics
[...]

======================================================================
FAIL: assertApproxEqual (test.test_statistics.NumericTestCase)
Doctest: test.test_statistics.NumericTestCase.assertApproxEqual
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_statistics.NumericTestCase.assertApproxEqual
  File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 153, in assertApproxEqual

----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 165, in test.test_statistics.NumericTestCase.assertApproxEqual
Failed example:
    class MyTest(NumericTestCase):
        def test_number(self):
            x = 1.0/6
            y = sum([x]*6)
            self.assertApproxEqual(y, 1.0, tol=1e-15)
        def test_sequence(self):
            a = [1.001, 1.001e-10, 1.001e10]
            b = [1.0, 1e-10, 1e10]
            self.assertApproxEqual(a, b, rel=1e-3)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics.NumericTestCase.assertApproxEqual[0]>", line 1, in <module>
        class MyTest(NumericTestCase):
    NameError: name 'NumericTestCase' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 177, in test.test_statistics.NumericTestCase.assertApproxEqual
Failed example:
    suite = unittest.TestLoader().loadTestsFromTestCase(MyTest)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics.NumericTestCase.assertApproxEqual[3]>", line 1, in <module>
        suite = unittest.TestLoader().loadTestsFromTestCase(MyTest)
    NameError: name 'MyTest' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 178, in test.test_statistics.NumericTestCase.assertApproxEqual
Failed example:
    unittest.TextTestRunner(stream=StringIO()).run(suite)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics.NumericTestCase.assertApproxEqual[4]>", line 1, in <module>
        unittest.TextTestRunner(stream=StringIO()).run(suite)
    NameError: name 'suite' is not defined


======================================================================
FAIL: _DoNothing (test.test_statistics)
Doctest: test.test_statistics._DoNothing
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_statistics._DoNothing
  File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 99, in _DoNothing

----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 112, in test.test_statistics._DoNothing
Failed example:
    approx_equal(12.345, 12.346, tol=1e-3)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._DoNothing[0]>", line 1, in <module>
        approx_equal(12.345, 12.346, tol=1e-3)
    NameError: name 'approx_equal' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 114, in test.test_statistics._DoNothing
Failed example:
    approx_equal(12.345e6, 12.346e6, tol=1e-3)  # tol is too small.
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._DoNothing[1]>", line 1, in <module>
        approx_equal(12.345e6, 12.346e6, tol=1e-3)  # tol is too small.
    NameError: name 'approx_equal' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 120, in test.test_statistics._DoNothing
Failed example:
    approx_equal(12.345, 12.346, rel=1e-4)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._DoNothing[2]>", line 1, in <module>
        approx_equal(12.345, 12.346, rel=1e-4)
    NameError: name 'approx_equal' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 122, in test.test_statistics._DoNothing
Failed example:
    approx_equal(12.345e6, 12.346e6, rel=1e-4)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._DoNothing[3]>", line 1, in <module>
        approx_equal(12.345e6, 12.346e6, rel=1e-4)
    NameError: name 'approx_equal' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 131, in test.test_statistics._DoNothing
Failed example:
    approx_equal(12.345e6, 12.346e6, tol=1e-3, rel=1e-4)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._DoNothing[4]>", line 1, in <module>
        approx_equal(12.345e6, 12.346e6, tol=1e-3, rel=1e-4)
    NameError: name 'approx_equal' is not defined


======================================================================
FAIL: _calc_errors (test.test_statistics)
Doctest: test.test_statistics._calc_errors
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_statistics._calc_errors
  File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 25, in _calc_errors

----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 28, in test.test_statistics._calc_errors
Failed example:
    _calc_errors(100, 75)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._calc_errors[0]>", line 1, in <module>
        _calc_errors(100, 75)
    NameError: name '_calc_errors' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 30, in test.test_statistics._calc_errors
Failed example:
    _calc_errors(100, 100)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics._calc_errors[1]>", line 1, in <module>
        _calc_errors(100, 100)
    NameError: name '_calc_errors' is not defined


======================================================================
FAIL: approx_equal (test.test_statistics)
Doctest: test.test_statistics.approx_equal
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoine/cpython/default/Lib/doctest.py", line 2193, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_statistics.approx_equal
  File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 41, in approx_equal

----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 54, in test.test_statistics.approx_equal
Failed example:
    approx_equal(1.2589, 1.2587, tol=0.0003, rel=0)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics.approx_equal[0]>", line 1, in <module>
        approx_equal(1.2589, 1.2587, tol=0.0003, rel=0)
    NameError: name 'approx_equal' is not defined
----------------------------------------------------------------------
File "/home/antoine/cpython/default/Lib/test/test_statistics.py", line 56, in test.test_statistics.approx_equal
Failed example:
    approx_equal(1.2589, 1.2587, tol=0.0001, rel=0)
Exception raised:
    Traceback (most recent call last):
      File "/home/antoine/cpython/default/Lib/doctest.py", line 1324, in __run
        compileflags, 1), test.globs)
      File "<doctest test.test_statistics.approx_equal[1]>", line 1, in <module>
        approx_equal(1.2589, 1.2587, tol=0.0001, rel=0)
    NameError: name 'approx_equal' is not defined
msg212108 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2014-02-24 15:48
I don't know how to interpret this. Where can I find out more about refleak mode? Thanks.
msg212125 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-02-24 17:37
The best way to learn about the different testing modes is to run
"./python -m test -h".

Basically "-R" executes the given tests several times in a row. This failure shows that test_statistics doesn't like being executed several times, which is a bug.

(the same problem arises with "-F" instead of "-R")
msg212126 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-02-24 17:38
(ah, actually "-F" seems to work fine with test_statistics :-))
msg218156 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-05-09 12:20
#20746 seems to have a patch for this.
msg225929 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2014-08-26 20:20
This issue can be closed.
After changeset 7bc53cf8b2df by Zachary Ware in issue 22104:

./python -m test -R3:3 test_statistics

is ok now.
msg226052 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-29 05:42
Thanks, Xavier!
History
Date User Action Args
2014-08-29 05:42:19zach.waresetstatus: open -> closed
superseder: test_asyncio unstable in refleak mode
messages: + msg226052

resolution: fixed
stage: needs patch -> resolved
2014-08-26 20:20:05xdegayesetnosy: + zach.ware
messages: + msg225929
2014-05-09 12:20:45ezio.melottisetnosy: + xdegaye
messages: + msg218156
2014-05-09 11:27:53ezio.melottisetnosy: + ezio.melotti
stage: needs patch

versions: + Python 3.5
2014-02-24 17:38:19pitrousetmessages: + msg212126
2014-02-24 17:37:58pitrousetmessages: + msg212125
2014-02-24 15:48:14steven.dapranosetmessages: + msg212108
2014-02-23 17:17:46pitroucreate