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

Duplicate filenames reported when filename contains uppercase letters on windows. #203

Closed
nedbat opened this issue Oct 17, 2012 · 11 comments
Labels
bug Something isn't working report

Comments

@nedbat
Copy link
Owner

nedbat commented Oct 17, 2012

Originally reported by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


Our source code contains python files that have uppercase letters in the filenames. On windows, when running tests that utilize these source files, the coverage report is showing the files with uppercase letters twice in the list - once with the upper case letters, once in all lower case.

I have figured out why:

In data.py:
It seems touch_file is called for all files. Passed into it is the filename that contains upper cased letters.

For files that are partly coveraged, we also call add_line_data. The filename passed into here is the canonical filename which is gotten from File.py, FileLocator.canonical_filename. This function calls os.path.normcase, which lowers the case on windows. Uh-oh! We don't do that when we call touch_file, so files show up in the report twice when they have uppercased letters..

How to fix? I'm not sure what the right solution is, but my guess is we should call the canonical_filename function before calling touch_file. This would be in control.py.

Let me know if you have any questions.. My fix is just a suggestion... Thanks!


@nedbat
Copy link
Owner Author

nedbat commented Oct 17, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


I should have mentioned FileLocator.canonical_filename calls FileLocator.abs_path, and that is where the os.path.normcase is called.

@nedbat
Copy link
Owner Author

nedbat commented Oct 17, 2012

What kind of report are you using? Are you moving files between operating systems, or is this purely on Windows?

@nedbat
Copy link
Owner Author

nedbat commented Oct 17, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


This is purely windows - files are not being moved anywhere..

@nedbat
Copy link
Owner Author

nedbat commented Oct 17, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


I'm just dumping the results to screen. I've recreated it, however, using an html report as well.

@nedbat
Copy link
Owner Author

nedbat commented Oct 18, 2012

Thomas, I'm having trouble reproducing this. Could you show me a small reproducible case?

@nedbat
Copy link
Owner Author

nedbat commented Oct 18, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


I have attached a zip file with a really simple example. I'm running pytest, however, and just run with the following arguments (in the same dir as the files): py.test testTest.py --cov .

I realized while creating this simple example that the problem only shows up once I add the __init__.py file to the mix. At that point the coverage output goes from showing just testtestto showing SkippedTest, __init__, testTest, and testtest

@nedbat
Copy link
Owner Author

nedbat commented Oct 18, 2012

Any chance we can make it happen without py.test?

@nedbat
Copy link
Owner Author

nedbat commented Oct 19, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


I tried, but no success. I'm not able to get SkippedTest to show up in the list. I'm probably not use the right switch is my guess. I can only get testtest to show up. My guess is that I don't know the switch to get the touch_file command to execute, but that is only a guess..

@nedbat
Copy link
Owner Author

nedbat commented Nov 8, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


Ned - figured it out. Please use the attached .coveragerc file as well. That is, drop into the same location as the other files. You'll need to change the path in the .coveragerc file to wherever you place the files. It should point to directory that the files are in.

When you do this, you'll notice testTest and testtest are reported on.

As a side note, I did find another issue along the same lines. It seems I can't use source and omit the way I would expect it to work. Using the same example, let's say I specify the [run] source=. Then, I specify omit=SkippedTest. It won't omit SkippedTest because source will override omit..

What I have are a couple of py files in my package that don't run with the app (they are either experiments/developer demos). I want everything in the package included in coverage, except for these couple of files (ideally, I want them to show up in the list, but have all lines excluded from coverage). Is there a way to do this? I can create another issue for this, if you want, or maybe post this in the forums.. Thanks!

@nedbat
Copy link
Owner Author

nedbat commented Nov 8, 2012

Original comment by Thomas Maslach (Bitbucket: tmaslach, GitHub: tmaslach)


Ignore the second 2 paragraphs above for now.. I know how to do it through coverage now, I just need to figure out how to do it via pytest... However, the first 2 paragraphs are relevant to this bug..

@nedbat
Copy link
Owner Author

nedbat commented Nov 11, 2012

Fixed in <<changeset 31ca39cb1da5 (bb)>>.

@nedbat nedbat closed this as completed Nov 11, 2012
@nedbat nedbat added minor bug Something isn't working report labels Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working report
Projects
None yet
Development

No branches or pull requests

1 participant