Open davidak opened 7 years ago
I faced the same error and digged a bit (using nose 1.3.7 pip-installed on my Ubuntu). Here is what happens in my case:
I have ./tests directory with various test«sth».py files and a few utl«sth».py files
In crashing case, the function sameModule from importer.py is called with args
It doesn't find __path__
attribute, so enters elif for __file__
As __file__
is equal to 'utl_helpers.pyc', the function _dirname_if_file returns just '' for it (os.path.dirname('utl_helpers.pyc') yields '')
So mod_paths is calculated to be ['']
Later on this '' is passed to _samefile and crashes.
I am not 100% sure what exactly triggers the error (probably having utility.py imported from more than one test). Still, the problem disappeared once I changed _dirname_if_file to:
def _dirname_if_file(self, filename):
# We only take the dirname if we have a path to a non-dir,
# because taking the dirname of a symlink to a directory does not
# give the actual directory parent.
if os.path.isdir(filename):
return filename
else:
return os.path.dirname(os.path.abspath(filename))
(added os.path.abspath)
I think the reason is that something in package's "__init__.py" breaks nose importer logic. I had the same problem, when I removed
__path__ = __file__
from my '__init__.py' file, the problem was fixed.
I'm packaging a python package for NixOS that uses nose for testing.
The tests run locally and on Travis CI, but fails on build with Nix (Package Manager of NixOS).
https://travis-ci.org/davidak/PyZufall/jobs/203049456
Error with Nix
Full output: https://gist.github.com/davidak/7a8ff78b5fc08864fd23fda63ae5995b
What is happening there and how can i fix it?
nosetests version 1.3.7