Thursday, April 28, 2016

Setup Python github project

1. pytest: let say we have a file linear_regression.py under current directory, we will need to create a file under tests/test_abc.py, that imports linear_regression.py, and do testing. We then can run
> py.test --cov=packagename --pyargs packagename
to perform unit testing. It will report coverage percentage, which roughly means how many lines of codes are covered with unit testing.
2. doctest: under the definition of a function, we can include document testing, e.g.
def f(x):
"""
Examples:
>>> f(2)
4
"""
return x**2
Then we can run doctest that check for correct result
3. style test: to make sure that our codes are in good styles, we can do
> py.test --pep8 --flakes --pyargs hyperemble
4. Travis: to make sure that our codes work across platform, across different version of Python, we can use travis. Upload the code to github, and travis will perform test across different platform for correctness




1. Create a github repository with README.md and license,
2. Create a setup.py
3. Create a Makefile that contains make style and make test
4. Add Travis CI support
5. Add requirements.txt for the require packages

No comments:

Post a Comment