Archives Sept. 1, 2011

Run coverage of your Django test suite...

Since there is a 4-year old still-open ticket on this, thought I'd provide a simple recipe for getting a coverage report on your Django project:

pip install coverage
coverage run path/to/ test myapp
coverage report -m --include="*myapp*"
coverage erase # clean up afterward/between runs

Sure, it's not --with-coverage, but ...

Continue reading

Choices for Foo?

The choices_for_FOO hook would allow a model to restrict the choices for a given field based on e.g. another field (common requirement where you have row-level authorization and need to restrict choices to the set of records accessible by the auth-row attached to this object).  It's currently a patch attached to a 5 ...

Continue reading

Requests Library is nice

Experimented with replacing a few urllib2 calls in a product today with the requests library.  Yes, requests really is nice (sat down and read through the code last night).  One thing that's not obvious from the docs, to do digest auth, you pass (username, password, 'digest') as the auth parameter.  There are a number ...

Continue reading

Previous day

Aug. 19, 2011

Next day

Sept. 6, 2011