Open kalekundert opened 1 year ago
Merging #143 (3edf2e9) into main (ec406ff) will decrease coverage by
0.42%
. The diff coverage is92.00%
.:exclamation: Current head 3edf2e9 differs from pull request most recent head 128a178. Consider uploading reports for the commit 128a178 to get more accurate results
Here's a screenshot:
As discussed in #105, this PR adds some options to have
debug()
output stack traces.While I was working on this, I realized that there are two reasonable way to format stack traces. The first is to match the existing style that
debug()
uses:The second is to match the style that python itself uses:
Both styles have the same information, but the python style is more verbose and includes the actual text of the line in question. I decided to use the devtools style, because it "fits" better and I didn't think the extra verbosity would be that helpful for the kinds of things I envision debugging with this feature, but I'm not confident in this decision. I might change my mind after living with it for a while. If anyone else has an opinion on which style to use, I'd be happy to hear it.
Another aspect of this PR that I should draw attention to is the new unit tests. I think that all the stack trace tests need to happen in subprocesses, because otherwise the stack traces would include ≈20 pytest frames (which would be likely to change between different versions of pytest). To avoid duplicating the boilerplate required to run a test in a subprocess, I decided to write these tests using two of my own libraries:
parametrize_from_file
andpytest_tmp_files
. The specific code I wrote here is very similar to this example from the documentation. I think that I wrote these tests in the most understandable, maintainable way, but I'd understand if you were skeptical about adding two relatively unknown dependencies to your project. If so, let me know and I'd be happy to rewrite the tests using vanilla pytest. (Also, I had to regenerate therequirements/testing.txt
file, and I'm not sure I did that in the right way.)