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

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

  • usually the most important part of optimization
  • debug lines of django code with debug_sql
  • use the sql in dbshell and experiment
    • describe select ...
    • show create table ...
    • alter table ... add index ...

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