[issue19119] duplicate test name in Lib/test/test_heapq.py

Xavier de Gaye report at bugs.python.org
Sat Sep 28 22:53:22 CEST 2013


New submission from Xavier de Gaye:

There are two test_get_only methods. The patch provides a partial
fix, but removes the following two lines from the first method as the
execution of these lines fails:

  for f in (self.module.nlargest, self.module.nsmallest):
      self.assertRaises(TypeError, f, 2, GetOnly())

because heapq.nlargest is stuck in an infinite loop when the sequence
does not have a length. This seems to be a bug in nlargest. See the
following test that runs with 100 % cpu usage.

$ ./python
Python 3.4.0a2+ (default:f6792f734fcc, Sep 28 2013, 17:09:46) 
[GCC 4.3.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class GetOnly:
...     "Dummy sequence class defining __getitem__ but not __len__."
...     def __getitem__(self, ndx):
...         return 10
... 
>>> import heapq
>>> heapq.nlargest(2, GetOnly())
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Lib/heapq.py", line 455, in nlargest
    result = _nlargest(n, it)
  File "<stdin>", line 3, in __getitem__
KeyboardInterrupt
>>>

----------
components: Library (Lib)
files: duplicate_test_name.patch
keywords: patch
messages: 198550
nosy: rhettinger, stutzbach, xdegaye
priority: normal
severity: normal
status: open
title: duplicate test name in Lib/test/test_heapq.py
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file31898/duplicate_test_name.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19119>
_______________________________________


More information about the Python-bugs-list mailing list