nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 395 forks source link

Nosetests could not find any unit-test in Windows Partition mounted in Linux #1058

Open wkcn opened 6 years ago

wkcn commented 6 years ago

Hi, there.

I mounted a windows partition or windows folder in Arch Linux.

Then I moved my project into the windows folder.

I ran the script nosetests, and it showed that Ran 0 tests, namely nose couldn't find any unit-test.

However, it works when nosetests a specific python script.

And nosetests will find all unit-test if I move my project into Linux Partition.

So, I made these tests.

  1. Move other project(like: librosa) into the windows folder then ran nosetests.
  2. Mount the windows folder in the linux which is in physics machine via ntfs-3g, then nosetests the project in the windows folder.
  3. Mount the windows folder in the linux which is in VMware Workstation via shared folder, then nosetests the project in the windows folder.

The results are all that nosetests shows Ran 0 tests.

I think the reason may be that the user permission is different between windows folder and linux folder.

I found the reason is that the user permission of an unit-test file is different on different OS. The function def is_executable(file) in nose/utils.py wrongly recognizes an unit-test file on Windows Partition as an executable file.

def is_executable(file):
    if not os.path.exists(file):
        return False
    st = os.stat(file)
    return bool(st.st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))

For a unit-test file, the permissions are below:

WINDOWS:0b1000000111111111
LINUX  :0b1000000110100100
MASK   :0b0000000001001001

Notice that the last nine bits all are 1s on the mounted Windows Partition.