Skip to content

Commit 3a2b6f4

Browse files
mdmedleyageitgey
authored andcommitted
Fix For Travis Test Step (ageitgey#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.
1 parent 99641c5 commit 3a2b6f4

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

.travis.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ before_install:
1212
- sudo apt-get install -qq cmake python-numpy python-scipy libboost-python-dev
1313
- pip install git+https://github.com/ageitgey/face_recognition_models
1414

15-
install: pip install -r requirements.txt
15+
install:
16+
- pip install -r requirements.txt
17+
- pip install tox-travis
1618

17-
script: python -m tests.test_face_recognition
19+
script: tox

face_recognition/cli.py

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import warnings
88
import face_recognition.api as face_recognition
99

10+
1011
def scan_known_people(known_people_folder):
1112
known_names = []
1213
known_face_encodings = []
@@ -52,6 +53,7 @@ def test_image(image_to_check, known_names, known_face_encodings):
5253
def image_files_in_folder(folder):
5354
return [os.path.join(folder, f) for f in os.listdir(folder) if re.match(r'.*\.(jpg|jpeg|png)', f, flags=re.I)]
5455

56+
5557
@click.command()
5658
@click.argument('known_people_folder')
5759
@click.argument('image_to_check')
@@ -63,5 +65,6 @@ def main(known_people_folder, image_to_check):
6365
else:
6466
test_image(image_to_check, known_names, known_face_encodings)
6567

68+
6669
if __name__ == "__main__":
6770
main()

setup.cfg

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,17 @@ replace = __version__ = '{new_version}'
1515
universal = 1
1616

1717
[flake8]
18-
exclude = docs
18+
exclude =
19+
.github,
20+
.idea,
21+
.eggs,
22+
examples,
23+
docs,
24+
.tox,
25+
bin,
26+
dist,
27+
tools,
28+
*.egg-info,
29+
__init__.py,
30+
*.yml
1931
max-line-length = 160

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
]
2020

2121
test_requirements = [
22-
# TODO: put package test requirements here
22+
'tox',
23+
'flake8'
2324
]
2425

2526
setup(

tests/test_face_recognition.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def test_compare_faces(self):
112112
face_encoding_b1]
113113

114114
match_results = api.compare_faces(faces_to_compare, face_encoding_a1)
115-
self.assertIs(match_results[0], True)
116-
self.assertIs(match_results[1], True)
117-
self.assertIs(match_results[2], False)
115+
self.assertTrue(match_results[0])
116+
self.assertTrue(match_results[1])
117+
self.assertFalse(match_results[2])
118118

119119
def test_command_line_interface(self):
120120
target_string = '--help Show this message and exit.'

tox.ini

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[tox]
2+
envlist =
3+
py27
4+
py34
5+
py35
6+
py36
7+
flake8
8+
9+
10+
[travis]
11+
python =
12+
2.7: py27, flake8
13+
3.4: py34, flake8
14+
3.5: py35, flake8
15+
3.6: py36, flake8
16+
17+
18+
[testenv]
19+
commands =
20+
python setup.py test
21+
22+
23+
[testenv:flake8]
24+
deps =
25+
flake8
26+
27+
commands =
28+
flake8

0 commit comments

Comments
 (0)