Skip to content

Commit

Permalink
Tests: Generalize to Python 2 and 3. Run Python 2 by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Amos committed Apr 24, 2017
1 parent 71ee6ee commit fe8f73e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

cd $(dirname $0)

nosetests -v
nosetests-2.7 -v
5 changes: 3 additions & 2 deletions tests/openface_batch_represent_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import shutil
import tempfile
import sys

import numpy as np
np.set_printoptions(precision=2)
Expand All @@ -40,7 +41,7 @@ def test_batch_represent():

workDir = tempfile.mkdtemp(prefix='OpenFaceBatchRep-')

cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
os.path.join(workDir, 'aligned')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand All @@ -49,7 +50,7 @@ def test_batch_represent():
print(err)
assert p.returncode == 0

cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
os.path.join(workDir, 'aligned')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand Down
15 changes: 8 additions & 7 deletions tests/openface_demo_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import re
import shutil
import tempfile
import sys

from subprocess import Popen, PIPE

Expand All @@ -28,7 +29,7 @@


def test_compare_demo():
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'compare.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'compare.py'),
os.path.join(exampleImages, 'lennon-1.jpg'),
os.path.join(exampleImages, 'lennon-2.jpg')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand All @@ -39,7 +40,7 @@ def test_compare_demo():


def test_classification_demo_pretrained():
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
'infer',
os.path.join(openfaceDir, 'models', 'openface',
'celeb-classifier.nn4.small2.v1.pkl'),
Expand All @@ -52,7 +53,7 @@ def test_classification_demo_pretrained():


def test_classification_demo_pretrained_multi():
cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
'infer', '--multi',
os.path.join(openfaceDir, 'models', 'openface',
'celeb-classifier.nn4.small2.v1.pkl'),
Expand All @@ -70,7 +71,7 @@ def test_classification_demo_training():

workDir = tempfile.mkdtemp(prefix='OpenFaceCls-')

cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
os.path.join(workDir, 'aligned')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand All @@ -79,7 +80,7 @@ def test_classification_demo_training():
print(err)
assert p.returncode == 0

cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
os.path.join(workDir, 'aligned')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand All @@ -97,7 +98,7 @@ def test_classification_demo_training():
print(err)
assert p.returncode == 0

cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
'train',
os.path.join(workDir, 'reps')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand All @@ -106,7 +107,7 @@ def test_classification_demo_training():
print(err)
assert p.returncode == 0

cmd = ['python3', os.path.join(openfaceDir, 'demos', 'classifier.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'demos', 'classifier.py'),
'infer',
os.path.join(workDir, 'reps', 'classifier.pkl'),
os.path.join(lfwSubset, 'raw', 'Adrien_Brody', 'Adrien_Brody_0001.jpg')]
Expand Down
5 changes: 3 additions & 2 deletions tests/openface_neural_net_training_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import os
import shutil
import sys

import numpy as np
np.set_printoptions(precision=2)
Expand All @@ -37,7 +38,7 @@ def test_dnn_training():
lfwSubset), "Get lfw-subset by running ./data/download-lfw-subset.sh"

imgWorkDir = tempfile.mkdtemp(prefix='OpenFaceTrainingTest-Img-')
cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
os.path.join(imgWorkDir, 'aligned')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand All @@ -46,7 +47,7 @@ def test_dnn_training():
print(err)
assert p.returncode == 0

cmd = ['python3', os.path.join(openfaceDir, 'util', 'align-dlib.py'),
cmd = [sys.executable, os.path.join(openfaceDir, 'util', 'align-dlib.py'),
os.path.join(lfwSubset, 'raw'), 'align', 'outerEyesAndNose',
os.path.join(imgWorkDir, 'aligned')]
p = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
Expand Down

0 comments on commit fe8f73e

Please sign in to comment.