I’m writing a python library (speedcurve.py). At work, we’re using SpeedCurve to track our web performance. SpeedCurve’schangelog reveals can trigger a deployment (and a series of tests). I’m replacing our curl+ansible commands with this. I plan on integrating this with slack as well.
This project is heavily influenced by github3.py. I’ve been contributing frequently (plan on continuing to) and find it elegant. You’ll notice A LOT of similarities.
- For this project, I want the following up front:
-
- Proper Documentation
- 100% test coverage and flake8 checks
- Integration with Travis CI
This post focuses on configuring tox to execute coverage.
Configure tox + coverage
Since tox does NOT play nicely with pipes (|), this simple shell scripts checks for 100% test coverage:
1 2 3 4 |
<span class="ch">#!/bin/sh</span> coverage run --source speedcurve -m py.test coverage report <span class="p">|</span> tail -n <span class="m">1</span> <span class="p">|</span> grep <span class="s1">'^TOTAL.*100%$'</span> |
This goes in tox.ini
1 2 3 |
<span class="o">[</span>testenv:coverage<span class="o">]</span> <span class="nv">commands</span> <span class="o">=</span> ./coverage-check.sh |