Commit c63edd99 authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

added hooks and unit tests

parent 7b46bd6b
# this hook is in SCM so that it can be shared
# to install it, create a symbolic link in the projects .git/hooks folder
# i.e. - from the .git/hooks directory, run
# $ ln -s ../../git-hooks/ pre-commit
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git commit --no-verify'
# stash any unstaged changes
git stash --keep-index -q
# run the tests
echo " pre-commit tests ..."
python tfields test &> /tmp/git-pre-push-tests.log
# python -m unittest discover -s test -p 'unitTest_*py' &> /tmp/git-pre-commit-tests.log
# ./ &> /tmp/git-pre-commit-tests.log
# store the last exit code in a variable
# unstash the stashed changes
git stash pop -q
if [ $RESULT -ne 0 ]
echo "Test failed! Log record at /tmp/git-pre-push-tests.log"
echo "... OK"
# return the './gradlew test' exit code
exit $RESULT
import tfields
import numpy as np
from import x, y
import unittest
from tempfile import NamedTemporaryFile
......@@ -10,6 +9,7 @@ import sympy # NOQA: F401
ATOL = 1e-8
class Base_Test(object):
Testing derivatives of Points3D
Run doctests on module call
Run tests on module call with argument test
def runDoctests():
import doctest
import pathlib
import sys
import unittest
import doctest
import pathlib
def run_doctests():
Find all doctests and execute them
parent = pathlib.Path(__file__).parent
for f in list(parent.glob('**/*.py')):
doctest.testfile(str(f.relative_to(parent))) # , verbose=True, optionflags=doctest.ELLIPSIS)
def load_unittests(loader=None, suite=None):
if loader is None:
loader = unittest.TestLoader()
if suite is None:
suite = unittest.TestSuite()
parent = pathlib.Path(__file__).parent.parent
for f in list(parent.glob('*/test*.py')):
sys.path.insert(0, str(f.parent))
mod = __import__('.py'))
for test in loader.loadTestsFromModule(mod):
return suite
def run_unittests():
if __name__ == '__main__':
if len(sys.argv) > 1:
arg = sys.argv.pop(1)
if arg == 'test':
print "Run doctests"
print "Run unit tests"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment