EuroPython 2010 – Talks of Interest
May 29, 2010
The provisional timetable of talks for EuroPython 2010 is now available. I must admit, the tutorials look pretty good too, but I’m going to have to give them a miss.
So, what am I thining of attending?
Monday 19th July
- New and Improved – Michael Foord
- Development Process of Python – Ezio Melotti
- Python and Selenium Testing – Raymond Hettinger
- Django and the Semantic Web – Zachary Vose
- A Case for Accessibility – Stuart Bowness
- Open Data and Coding – David Read
- KBUS: A Simple Messaging System – Tony Ibbs
Tuesday 20th July
- Appstats – Guido van Rossum
- Arduino and Python – Michael Sparks
- Realtime Web with Eventlet – Ben Ford
- Intro to Functional Programming – Michele Simionato
- Robust Python Programs – Stefan Schwarzer
- Fun with Databases and Django – Andrew Godwin
…and a clash between…
- Deferred Gratification – Terry Jones
- Pythonic Parallelism with CSP – Russel Winder
Wednesday 21st July
- Taming Twisted with Generators – Raymind Hettinger
- Mobi: A Mobile User Agent Lib – Kit Blake
- Web Collaboration and Python – Paul Boddie
- Custom Runtimes with PyPy – Henrik Vendelbo
- Python for JavaScript Apps – Thomas Herchenroeder
- A Python’s DNA – Erik Groeneveld
- Lighting Strikes Thrice – Harald Armin Massa
Thursday 22nd July
- Building a Python Web App – Stuart Bowness
- NoSQL, what’s the deal? – Mark Ramm
- NoSQL for Dummies – Tobias Ivarsson
- Scaling Python at GeekNet – Mark Ramm
- Realtime Websites with Python – Henrik Vendelbo
Coverage.py
May 1, 2010
I finally had a chance to try coverage.py, a Python code coverage tool which is maintained by Ned Batchelder. I’m liking it a lot: it’s minimal fuss to set up and use, yet very useful indeed.
When you’ve installed coverage, it should be on your path. Taking my work-in-progress PyGame code as an example, I ran coverage on the test suite:
$ coverage run run_tests.py
The test suite runs as normal:
$ coverage run run_tests.py ................................................. ---------------------------------------------------------------------- Ran 49 tests in 0.006s OK $
Coverage writes the results to a .coverage file. To view this as a plain text report:
$ coverage report Name Stmts Exec Cover --------------------------------------------- constants 6 6 100% domain/__init__ 1 1 100% domain/deployment 27 23 85% domain/game_date 48 48 100% domain/unit 18 14 77% infrastructure/__init__ 1 1 100% infrastructure/storage 12 12 100% run_tests 4 4 100% tests/__init__ 3 3 100% tests/test_deployment 94 94 100% tests/test_game_date 64 64 100% tests/test_unit 57 57 100% --------------------------------------------- TOTAL 335 327 97% $
But for the best results, you can create an HTML report:
$ coverage html $
This writes HTML to an htmlcov directory, which can be viewed in a browser. The HTML report provides not only the summary listed in the plain text report, but links to pages for each source file. Each source listing is highlighted to indicate where code coverage is present and where code coverage is missing. Simple, but very, very useful. I’ve used the reports to improve the test suite’s coverage, and even identified code that could be removed. As you can see above, domain/deployment.py and domain/unit.py need better code coverage, which is something I’m aware needs to be addressed next as it will help with some upcoming changes.
One caveat is that coverage can only provide code analysis for code touched by your test suite. There are two areas of the code missing from the above report: the first is the source that binds the game together, since it’s not referenced by the test suite. More importantly, I mentioned I don’t have UI tests yet: since no UI code is called by the test suite, it doesn’t show on the report.
Something else to mention is it only tells you tests have touched sections of code – it’s up to you to ensure your test suite properly exercises that code.
Very cool, and thought I’d share in case you hadn’t seen this tool before.
Coverage can be obtained from http://pypi.python.org/pypi/coverage