# content of: tox.ini , put in same dir as setup.py [tox] envlist = py26,py27 [testenv] deps=pytest # install pytest in the venvs commands=pytest # or 'nosetests' or ...
Use Docker (if suitable to the software) for testing multiple pull-requests testing parallelly
Let Jenkins do the deployment to share the knowhow
Fully CI/CD autumation isn't far far away
Avoid keeping failing or
What it is all for
Keep failures before release
It's really hard. After release:
Even AWS Serveless Can Fail
My HeardBleed with OpenSSL
A Little Less Surprise?
Forget it, lets go back to CODE!
Don't forget it please 🙇
Back to Python World Finally!
2 strategieswill be focus here
Strategy 1. Show Me Errors Early
Some tools
IPython
Code Linter on IDE/Editors/CI
yapf
py.test
hyposesis
IPython (& Jupyter Notebook)
Evaluate behaviors step by step
Explore current environment and variables
Consider use pdb for exceptions
Step by Step Extension
Tip: Install IPython first
Pyramid pshell --development.ini
pyramid_debugtoolbar & pyramid_ipython
Django Debug Toolbar
Django python manage.py shell
Code Linter on IDE/Editors/CI
Super helpful for human typo
Vim: syntastic, ale (with flake8)
Sublime Text Linter
Most IDEs: built-in
Concept: WYSWYG
What you see is what you get
See it right right away!
google/yapf
... based off of 'clang-format' ... In essence, the algorithm takes the code and reformats it to the best formatting that conforms to the style guide, ...
even if the original code didn't violate the style guide.
Tips of using yapf
Can be used to format thoudsands of legacy Python code that is hard to read by our PEP8 built-in eyes.
Many options including Google and Facebook style to taste
YAPF is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.
py.test
py.test
makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries.
Tips of using py.test
Use it even Python and Django built-in unittest
Super handy to test a single module by pytest app/tests/test_a_single.py
with pytest-cov and --junitxml for Jenkins
with --lf to just test last failures
hyposesis
... lets you write tests which are parametrized by a source of examples, and then generates simple and comprehensible examples that make your tests fail.