Travis and tox revisited

Two years on, and I still love the combination of tox and Travis. I still write changes to my tox.ini and .travis.yml files separately, despite having written a tool for this. It occurred to me yesterday that there was a better way of writing this now – since tox now has a command for listing out … [Read more…]

Easy testing with Travis and tox

I love tox – it’s a great tool for checking that your Python packages are installable, and that you support all the various configurations of Python versions and other package versions that you think you do.

Using code coverage to find bugs

Yesterday, I found two bugs whilst looking at a code coverage report. I tend to think that shooting for 100% code coverage adds unnecessary overheard – often the last few percent doesn’t give you much benefit, and takes a disproportionate amount of time to reach, but it’s useful to at least understand why particular lines … [Read more…]

Bulk Upgrading Django Sites

A new version of Django was released a couple of days ago. I’m currently at 11 sites using Django, so upgrading them all manually (which I did last time) is a pain. To help me out, I wrote a tiny Fabric script to spin through my sites, check if they’re using the version of Django … [Read more…]

Using a local cache for pip packages

I do a lot of development without an internet connection1, so being able to install packages into a virtual environment without a connection to PyPI is pretty useful.  Mostly on the train to and from work. ↩

Automated Deployment of Django Sites

I tried out Fabric a while ago, but never really got anywhere with it. Time passed, and I forgot it existed, and wrote my simple scripts for automating deployment of my various sites, using Paramiko. It was incredibly tedious, but meant I could deploy my sites from whatever computer I was on, provided I had … [Read more…]

Avoiding database queries with Haystack

Order(n) is a pretty bad idea. Originally, my SearchIndexes for Haystack looked a bit like this: Then, when someone ran a search, and I wanted to display a result, I’d load up a template (which template I loaded depended on grabbing the model name, as recommended in the docs), and any attributes of the model … [Read more…]

Faster Django Tests

A long while ago, I discovered that running Django tests is much faster if you use SQLite, and if you turn off South (this now seems pretty obvious, but at the time was a bit of a revelation to me).

Test-Driven Development with Django & South

I’d basically given up on attempting test-driven with Django, given the project I’m currently working on uses models with a lot of South migrations. Just building the database and running the migrations could take a minute or so when running manage.py test, and resetting the database to a clean state meant the test suite would … [Read more…]