I've used trace.py from the Python standard library for checking unit test coverage. To exclude docstrings? Disallow excluding “else” suites? Do something else completely?ĭo you know about trace.py in the standard library? Does coverage.py that you gave a link to have any advantages over it? The date on the web page (2001) seems to indicate that coverage.py was created when Python did not have a code coverage analysis tool in the standard library. Go back to the old parse technique, and hack up something Regular expression results (finding the markers) with the parse tree results (what So it’s impossible to match up line-oriented It has both suites of code, but the actual line with the “else:” on it isn’t So a single marker could do it like this: if _name_ = '_main_' : #-notrun-Īnd if we’re going to do that, then it should work uniformly for all suites: if alwaystrue :Īnd there’s the problem: the compiler module completely discards any trace of theĮlse. The end to allow it to be run from the command line, it would be nice if theĮntire suite could be marked without having to putĪ marker comment on every line. For example, if a module has a chunk of code at (the Python equivalent of a block in other languages) could be marked as Then I wanted to add another feature, so that an entire suite of statements It seemed like a no-brainer, and it all went very well. The compiler module is higher-level, returning a tree of nodes that corresponds more to the Making it difficult to distinguish a docstring from any other expression statement. The parser module returns a low-level, grammar-centric representation of the source text, Lines of code are executed, and parsing the source of the modules to understand which It works by using the debugging trace hook to record which That they would not be counted as missed lines. I also wanted to add some other features,įor example, the ability to mark lines of code as not expected to be run, so I wanted to fix it so that it understood docstringsįor what they were. I have a lot of docstrings, so the results It works well, but countsĭocstrings as missed lines of code. To measure the code coverage of some unit tests. I’ve been hacking on code this weekend, and I’ve managed to get myself stuck.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |