Translate Toolkit & Pootle

Tools to help you make your software local

User Tools


Our aim is that all new functionality is adequately tested.

Translate Toolkit

We use py.test for unit testing. You need at least py.test >= 1.0.0

To run the all tests in the current directory and its subdirectories.


to run tests in a specific test file.

py.test storage/

py.test functionality that we use

We use some of the py.test plugins for simplify testing


The recwarn plugin allows us to test for Warnings.

recwarn is a funcargs plugins which means that you need it in your test function parameters.

def test_example(recwarn):
    # do something
    w = recwarn.pop()
    # w.{message,category,filename,lineno}
    assert 'something' in str(w.message)

To test for DeprecationWarning it is even simpler:

from py.test import deprecated_call
def test_something():
    deprecated_call(function_to_run, arguments_for_function)

Will check that a function that we run raises a DeprecationWarning


The xfail decorator is part of the skipping plugin. xfail allows us to run tests that we expect to fail.

This allows you to do the following:

  • Build tests for functionality that we haven't implemented yet
  • Mark tests that will fail on certain platforms or Python versions
  • Mark out tests that we want to fix but haven't got round to fixing yet

The simplest form is the following:

def test_function():

You can also pass the following parameters:

  • xfail(“sys.version_info >= (3,0)”) - skip the test if certain condition is met.
  • xfail(…, run=False) - don't run the test but still regard it as xfailed
  • xfail(…, reason=“my reason”) - provide a reason for the xfail.


Run tests with Pootle 2.x this way:

./  test  pootle_store pootle_app

Some of the other Django applications also have tests, but don't run in our default setup, so it is probably best to ignore them for now. If you use Django 1.2, the tests should run out of the box, as long as you don't use database cache but rather in-memory cache or memcached. With older versions of Django, disable the page following middleware in pootle/

  • django.contrib.csrf.middleware.CsrfMiddleware
  • django.middleware.cache.UpdateCacheMiddleware
  • django.middleware.cache.FetchFromCacheMiddleware