bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

pyx files do not have a package, and doctests will not print if they fail #453

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a cython extension (pyx) with a doctest that fails in a libaray.
2. Compile library, generating a .so file from pyx file.
3. Run nose tests on said library.
4. Tests run, but when printing out the problems, the following happens:
File "/usr/local/lib/python2.7/dist-packages/nose/plugins/doctests.py", line 
366, in id
    if not name.startswith(pk):
TypeError: expected a character buffer object

What is the expected output? What do you see instead?
Doctest details

What version of the product are you using? On what operating system?
1.0.0, but the discriminating code is on the most recent version.

This fails because the extension is not .py. This causes the 
nose/util/getpackage function to return None, which fails when passed to 
str().startswith. I don't know if getpackage will work properly in the case of 
non-py files, so getpackage returning None is probably valid. However the 
DocTestCase.id function should probably handle the case when pk is None a bit 
better. As a suggestion: 
    if pk is None: pk = "<unknown package>"
Or something more valid.

Original issue reported on code.google.com by robertla...@gmail.com on 5 Sep 2011 at 11:07