August 2018
Beginner
160 pages
4h 8m
English
Pyannotate (https://github.com/dropbox/pyannotate) is a project that observes runtime type information and can use that information to insert type annotations into the source code, and pytest-annotate makes it easy to use with pytest.
Let's get back to this simple test case:
def highest_rated(series): return sorted(series, key=itemgetter(2))[-1][0]def test_highest_rated(): series = [ ("The Office", 2005, 8.8), ("Scrubs", 2001, 8.4), ("IT Crowd", 2006, 8.5), ("Parks and Recreation", 2009, 8.6), ("Seinfeld", 1989, 8.9), ] assert highest_rated(series) == "Seinfeld"
After installing pytest-annotate, we can generate an annotations file passing the --annotations-output flag:
λ pytest --annotate-output=annotations.json
This will ...
Read now
Unlock full access