How does coverage measurement work in Python?

If you’re writing serious Python you’re hopefully testing it, and if you’re doing any serious testing you are hopefully measuring how much code coverage you have. But how does code coverage measurement actually work? If I execute a test function and get back a result, how can I possibly tell which lines of code were […]

Why do Django views need an as_view() method?

One thing I’ve sometimes wondered about when using Django: Why do view objects need to be constructed in a special way? For those of you who haven’t used Django, a typical URL mapping scheme looks like this: urlpatterns = [ url(r’^login/$’, views.LoginView.as_view(), name=’login’), url(r’^logout/$’, views.LogoutView.as_view(), name=’logout’), # … ] This maps URLs to view classes […]

Smarter debug logging with q

I stumbled across an interesting looking library completely by chance the other day. It has the impossible-to-Google name of q, so I guess other people might have overlooked it as well. The idea is to deal with those cases that aren’t supposed to happen, but happen anyway: you’re working on a bug and want to […]