Skip to content

PooCon2016: Testing and debugging Pootle

phlax edited this page Oct 25, 2016 · 12 revisions

testing with pootle

  • coverage is up to around 93%
  • py.test
  • high test coverage facilitates rapid dev
  • machine linting
  • some doctests

Linting tools

  • flake8 - combined pep8 and pyflakes
  • pylint
  • csslint
  • eslint
  • isort
  • commands:
make lint-python
make lint-css
make lint-js

CI tools

  • travis.com
  • coveralls.io
  • codecov.io
  • landscape.io
  • requires.io
  • New Relic

introduction to pdb

  • swiss army knife of debugging
  • introspect local vars and test code
  • import pdb; pdb.set_trace()
  • import inspect; inspect.stack()[10]

sql debugging

debugging tests and optimizing

  • py.test -vv --debug.tests my-timings.txt
  • drill down to time-consuming tests and debug_sql
  • common optimizations
    • preventing duplicate calls
    • adding select_related or pre-initializing related objects
    • prefetching
    • values_list - sometimes with a ProxyAdapter (also Queryset.only() ?)
Clone this wiki locally