Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nose does not find tests on Windows due to casing of path #1106

Open
tjshewmake opened this issue Apr 30, 2020 · 0 comments
Open

nose does not find tests on Windows due to casing of path #1106

tjshewmake opened this issue Apr 30, 2020 · 0 comments

Comments

@tjshewmake
Copy link

The issue I'm experiencing seems to be pinpointed to the following lines of code:

nose/nose/loader.py

Lines 350 to 352 in 7c26ad1

if (self.config.traverseNamespace or not path) or \
os.path.realpath(
os.path.normcase(module_path)).startswith(path):

Within the above if statement, I see os.path.realpath(os.path.normcase(module_path)) when comparing to path, which is called a little earlier (in line 343)
path = os.path.normcase(os.path.realpath(path))

The problem is that you can get very different results when you call os.path.realpath(os.path.normcase(<your path>)) vs. os.path.normcase(os.path.realpath(<your path>)), and as a result, the if statement returns False on Windows for me. Here is the log statement:

nose.loader: DEBUG: Load tests from module path C:\jenkins\workspace\my_cli-windows-gerrit-build\src\tests?
nose.loader: DEBUG: path: c:\jenkins\workspace\my_cli-windows-gerrit-build\src\tests os.path.realpath(c:\jenkins\workspace\my_cli-windows-gerrit-build\src\tests): C:\jenkins\workspace\my_cli-windows-gerrit-build\src\tests

The suggested fix is for the if statement on L350 to call os.path.normcase(os.path.realpath(module_path)).startswith(path) to match the method order on L343. I can confirm that after making this change in the source code, all of my tests are detected by nose as expected.

greyfenrir added a commit to greyfenrir/nose that referenced this issue Jul 19, 2020
non-symmetric path manipulations (normcase(realpath()) vs
realpath(normcase)) caused problem with finding tests on Windows and
must be unified.
fix for issue nose-devs#1106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant