-
Notifications
You must be signed in to change notification settings - Fork 288
PooCon2016: Testing and debugging Pootle
Allan Nordhøy edited this page Apr 18, 2018
·
12 revisions
- Coverage is up to around 93%
- py.test
- High test coverage facilitates rapid dev
- Machine linting
- Some doctests
-
flake8
- combinedpycodestyle
(waspep8
) andpyflakes
pylint
csslint
eslint
isort
- Commands:
make lint-python
make lint-css
make lint-js
- travis.com
- coveralls.io
- codecov.io
- landscape.io
- requires.io
- New Relic
- Swiss army knife of debugging
- Introspect local vars and test code
import pdb; pdb.set_trace()
import inspect; inspect.stack()[10]
- https://github.com/translate/pootle/wiki/Debugging-with-pdb
- Usually the most important part of optimization
- Debug lines of django code with
debug_sql
- Use the SQL in
dbshell
and experimentdescribe select ...
show create table ...
alter table ... add index ...
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 aProxyAdapter
(alsoQueryset.only()
?) - iterator
- combining SQL
- splitting SQL
- We have a simple bit of middle-ware to debug log view SQL and provide timings
pytest_pootle.env
-
project0
,language0
,tp0
,store0
,vfolder0
- Default users - admin, system, default, member, member2
- Matrix of translation projects, stores, units, suggestions, submissions