I'm trying to understand how it would work. If I have a class app/sub1/sub2/code.py:MyClass, and I set package_depth to 2, then the XML report would have package="app.sub1", and class="MyClass"? Is that what you want? It seems odd to omit elements of the package. Wouldn't it be better to include all the information in the XML, and let the reporting tool hide information you don't want?
Maybe I don't understand how the XML report ends up displayed in your environment.
My use case is a django project with reports being displayed in jenkins. I think that's a relatively popular use case.
What this feature allows you to do is to create a report that track apps as single units within a django project. Django projects are designed to be modular by splitting up code into "apps". If you have a very big project, with lots of apps and lots of code/directories in apps it can get rather unwieldy when looking at a coverage report listing.
You can limit depth to 3 and in jenkins you can easily see report for each "app".
Jenkins has no feature to limit depth in this way and often people are submitting coverage reports to 3rd party jenkins hosts so adding/modifying this feature in jenkins isn't practical.
I agree that the report rendering software should have this feature as well but if I already have it working in coverage and there are unit tests for it, what's the harm in having this feature in upstream coverage.py? It's unlikely to be added to jenkins and with system admins who rely on official package distributions it'll be years before the feature makes it on jenkins servers :-)
@Lex Berezhny I've implemented this feature, though the code had change quite a bit, so I didn't merge the pull request. You can take a look at this commit: 7f119fda7183. One difference: you said the default should be 1 to match the current behavior. After I fixed the regression of not having an XML package name, the default should be 99 (every directory is a package).
Thanks for the pull request, and sorry it took so long for me to get to.