Fix For Travis Test Step (#20)

Replaces test command in .travis.yml so tests get run. Updates
Flake8 configuration. Adds Tox to handle testing of multiple Python
versions. Adds test dependencies to setup.py. Fixes bug in test.
This commit is contained in:
Marcus Medley 2017-03-20 10:20:18 -07:00 committed by Adam Geitgey
parent 99641c5052
commit 3a2b6f4acf
6 changed files with 53 additions and 7 deletions

View File

@ -12,6 +12,8 @@ before_install:
- sudo apt-get install -qq cmake python-numpy python-scipy libboost-python-dev
- pip install git+https://github.com/ageitgey/face_recognition_models
install: pip install -r requirements.txt
install:
- pip install -r requirements.txt
- pip install tox-travis
script: python -m tests.test_face_recognition
script: tox

View File

@ -7,6 +7,7 @@ import scipy.misc
import warnings
import face_recognition.api as face_recognition
def scan_known_people(known_people_folder):
known_names = []
known_face_encodings = []
@ -52,6 +53,7 @@ def test_image(image_to_check, known_names, known_face_encodings):
def image_files_in_folder(folder):
return [os.path.join(folder, f) for f in os.listdir(folder) if re.match(r'.*\.(jpg|jpeg|png)', f, flags=re.I)]
@click.command()
@click.argument('known_people_folder')
@click.argument('image_to_check')
@ -63,5 +65,6 @@ def main(known_people_folder, image_to_check):
else:
test_image(image_to_check, known_names, known_face_encodings)
if __name__ == "__main__":
main()

View File

@ -15,5 +15,17 @@ replace = __version__ = '{new_version}'
universal = 1
[flake8]
exclude = docs
exclude =
.github,
.idea,
.eggs,
examples,
docs,
.tox,
bin,
dist,
tools,
*.egg-info,
__init__.py,
*.yml
max-line-length = 160

View File

@ -19,7 +19,8 @@ requirements = [
]
test_requirements = [
# TODO: put package test requirements here
'tox',
'flake8'
]
setup(

View File

@ -112,9 +112,9 @@ class Test_face_recognition(unittest.TestCase):
face_encoding_b1]
match_results = api.compare_faces(faces_to_compare, face_encoding_a1)
self.assertIs(match_results[0], True)
self.assertIs(match_results[1], True)
self.assertIs(match_results[2], False)
self.assertTrue(match_results[0])
self.assertTrue(match_results[1])
self.assertFalse(match_results[2])
def test_command_line_interface(self):
target_string = '--help Show this message and exit.'

28
tox.ini Normal file
View File

@ -0,0 +1,28 @@
[tox]
envlist =
py27
py34
py35
py36
flake8
[travis]
python =
2.7: py27, flake8
3.4: py34, flake8
3.5: py35, flake8
3.6: py36, flake8
[testenv]
commands =
python setup.py test
[testenv:flake8]
deps =
flake8
commands =
flake8