Skip to content

PooCon2016: Testing and debugging Pootle

Allan Nordhøy edited this page Apr 18, 2018 · 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 pycodestyle (was 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

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() ?)
    • iterator
    • combining SQL
    • splitting SQL

Debugging views

  • We have a simple bit of middle-ware to debug log view SQL and provide timings

The test environment

  • pytest_pootle.env
  • project0, language0, tp0, store0, vfolder0
  • Default users - admin, system, default, member, member2
  • Matrix of translation projects, stores, units, suggestions, submissions
Clone this wiki locally