pycobertura
pycobertura copied to clipboard
Export JSON as a list of objects
First of all thanks for your wonderful project! 🎉
Current JSON layout (column-oriented) isn't really easy to consume. I propose we flip it like this:
{
"files": [
{
"Filename": "pycobertura/__init__.py",
"Stmts": 2,
"Miss": 0 ,
"Cover": "100.00%",
"Missing": ""
},
// ...
]
}
As a sidenote, I'd also like to shout out an excellent library called tablib, which supports a ton of formats out of the box and would probably be easier to use than maintaining a lot of different formatters by hand.
P. S. same applies to Yaml, of course.
If you're interested in implementing this, I can send in a PR sometime this week (hopefully :-)
@gro1m what do you think? I tend to agree with @notpushkin but since you implemented it I wanted to have your input and thoughts on it.
@notpushkin @aconrad
I think the format is totally feasible, with regards to the library I do not have yet an opinion on it, as I do not know it. Generally, from a maintenance perspective I think in-built solutions and as less external packages as possible is optimal, so maybe in future a decision between tabulate and tablib would have to be taken.
Regarding implementation: I am currently still looking at the pytest coverage issue, which is a release-blocker for Version 3.0 and the solution could be to switch to unittest, so that is maybe just a caveat that it might be good to come up with something small first, i.e. only json or maybe json and yaml and not all formats at once :)
@notpushkin How do you get along with this PR? It seems the changes the resolution of the pytest coverage issue brings will be minor, if this time I really have found the solution. For more info please look at: #140.
I'm marking this issue for milestone 3.0 since it would be a breaking change.
pycobertura-3.0.0 was released, I hope this release addresses this issue. Please reopen if not.