pombreda / python-nose

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

Nose incorrectly reloads a module during test finding #356

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Unpack the attached <noseimportbug.tgz> file
2. Run it with "python -m run -v --with-doctest" (in the noseimportbug 
directory)
3. The test failes with: AttributeError: 'NoneType' object has no attribute 
'path'

What is the expected output? What do you see instead?
Expected the test to succeed as the code only calls "sys.path". However
the imported module has been set to "None"

What version of the product are you using? On what operating system?
* nose version 0.11.1
* linux and OS X

Please provide any additional information below.
The nose imported reloads a module, this is fine for test modules but
for code modules with dependencies it may fail.

In this test case the module should not even be reloaded. The nose importer
incorrectly determines the module to be not the same as the file.

In the Importer class of the "nose.importer", the "sameModule" method now has a 
line:

new_path = os.path.dirname(os.path.normpath(filename))

This should probably be replaced with:

new_path = os.path.dirname(os.path.normpath(os.abspath(filename)))

As it is compared with absolute paths.

Original issue reported on code.google.com by post4ar...@gmail.com on 29 Jul 2010 at 11:06

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've included a patch that solves this specific testcase (by adding os.abspath)

Original comment by post4ar...@gmail.com on 29 Jul 2010 at 11:28

Attachments:

GoogleCodeExporter commented 9 years ago
Unfortunately this bug is still in nose version 1.0.0

BTW: os.abspath should be os.path.abspath

Original comment by post4ar...@gmail.com on 14 Jun 2011 at 8:58

GoogleCodeExporter commented 9 years ago
Thanks.  If you want to check out DEVELOPERS.txt and convert your suite to a 
regression test then we can integrate it quicker.

Original comment by kumar.mcmillan on 14 Jun 2011 at 3:15