664
edits
(adding migration section) |
No edit summary |
||
| Line 24: | Line 24: | ||
The resulting SQL will contain a lot more than you really need: it <code>ALTER</code>s every column. You should drop any statement that doesn't actually change anything, to make it easier for reviewers. | The resulting SQL will contain a lot more than you really need: it <code>ALTER</code>s every column. You should drop any statement that doesn't actually change anything, to make it easier for reviewers. | ||
== pdb and debugging == | |||
'''pdb''', the Python debugger, is a fantastic tool that lets open a shell at any point in the execution of a program with one line: | |||
import pdb; pdb.set_trace() | |||
There are a couple of tricks to using it with our test-suite. | |||
=== Enabling iPython === | |||
pdb's built-in shell is... OK, but iPython is better. To enable iPython in the pdb shell, run this: | |||
echo "alias i from IPython.Shell import IPShellEmbed as IPSh; IPSh(argv='')()" >> ~/.pdbrc | |||
Then in pdb, just type <code>i<enter></code> to drop into iPython in the same context. | |||
=== pdb and nose === | |||
pdb and nose have a love/hate relationship by default: nose captures stdout and prevents you from getting to the pdb prompt. On the other hand, nose also has switches to automatically drop into pdb on error or failure. | |||
./manage.py test # Cannot get into pdb | |||
./manage.py test -s # Tells nose not to capture stdout, can get to pdb | |||
./manage.py test --pdb # Drop into pdb if there's an error (E result) | |||
./manage.py test --pdb-fail # Drop into pdb if there's a failure (F result) | |||
== pip == | == pip == | ||
edits