Jan 17 2012

Snow leopard and Qt/PyQt 4.8.x won't work

If you try to install, even with Homebrew the latest version of Qt the 4.8.x, you may end up haing a surprise like that :

  1. ImportError: dlopen(/usr/local/lib/python/PyQt4/QtWebKit.so, 2): Symbol not found: _kCFWebServicesProviderDefaultDisplayNameKey
  2.   Referenced from: /Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit
  3.   Expected in: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

This is coming precisely from a Qt issue that don't seem to be resolved anytime soon, so anyway you're warned now, revert back to 4.7.x you have no choice. Except if you want to buy Lion :)

Vale


Jan 15 2012

Handle Celery-dependent tests in Django and with django-jenkins

So in your life, one of these days, you're going to realize you need tests, and that "maybe" you also need to test components that depend on several Celery tasks.

Well to help you make this day more productive and less painful, here's a few tips.

First to make it work with Django-celery, a pretty good but small documentation is available here http://ask.github.com/django-celery/cookbook/unit-testing.html it may seems small and not enough, but it actually is enough. To sum up all you need to make it work with ./manage.py test is to change the test runner to :

  1. TEST_RUNNER = 'djcelery.contrib.test_runner.CeleryTestSuiteRunner'

But it's not enough, soon when you think everything's over, you'll want to deploy and make it go through Jenkins's testing processes. Well i don't know about you but to me the django-jenkins project is quite a good one and i use it everyday but it has one flaw, it already as its designated TEST_RUNNER so if you try to execute your tests through ./manage.py jenkins it won't work and you'll get at least a Connection Refused error.

Here's how to fix this, the documentation says if you want to replace the TEST_RUNNER you may do so, but the class you'll use needs to inherit from django_jenkins.runner.CITestSuiteRunner and if you want the Celery tasks to work you need to use the djcelery.contrib.test_runner.CeleryTestSuiteRunner.

Fair enough, here's what i did. I created a new class :

  1. from django_jenkins.runner import CITestSuiteRunner
  2. from djcelery.contrib.test_runner import CeleryTestSuiteRunner
  3.  
  4. class MixedInTestRunner(CITestSuiteRunner, CeleryTestSuiteRunner):
  5.     pass

Why not ? and used it as such defining the new TEST_RUNNER by changing the settings's variable JENKINS_TEST_RUNNER to the newly created class.

And voilà.