Development/Testing

Testing Transifex's code

We use unit testing to validate that the components that make up the application are doing what they are supposed to do. If you're code for Tx (mainline, patches, fixes), please have tests attached for your changes. We're encouraging to have test cases written for bugs, replicating the problem (and validating the fix actually does fix it).

(To new contributors: writing test cases for open bugs, or for existing untested functionality is a great way to get started with hacking Tx's code.)

Testing with nose

First make sure that you have nose installed (python-nose package in fedora), Here's a sample run of Tx's tests:

$ nosetests
nosetests
......
----------------------------------------------------------------------
Ran 16 tests in 4.350s

OK

Turbogears uses the special configuration file test.cfg to setup various things (test db, variables) before running tests so you might want to take a look at it. test.cfg importing is triggered by 'from transifex import testutil' statement. So this should come before any other import that messes with db stuff (like "from turbogears import database").

Debugging unsuccessful tests

Debugging tests can be done with nosetests -v --pdb, and --pdb-failures, which drops you to a Python debugger right before the failed test. Handy debugger commands:

  • l: show surrounding code
  • bt: show backtrace
  • up, down: Go up and down
  • print <var>: Blah.

Further reading

Hopefully this list won't get too outdated.