Tests: Generalize to Python 2 and 3. Run Python 2 by default.

This commit is contained in:
Brandon Amos 2017-04-24 18:01:10 -04:00
parent 71ee6ee747
commit fe8f73eb69
4 changed files with 15 additions and 12 deletions

View File

@ -4,4 +4,4 @@ set -e
cd $(dirname $0)
nosetests -v
nosetests-2.7 -v

View File

@ -18,6 +18,7 @@
import os
import shutil
import tempfile
import sys
import numpy as np
np.set_printoptions(precision=2)
@ -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)
@ -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)

View File

@ -19,6 +19,7 @@ import os
import re
import shutil
import tempfile
import sys
from subprocess import Popen, PIPE
@ -28,7 +29,7 @@ lfwSubset = os.path.join(openfaceDir, 'data', 'lfw-subset')
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)
@ -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'),
@ -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'),
@ -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)
@ -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)
@ -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)
@ -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')]

View File

@ -17,6 +17,7 @@
import os
import shutil
import sys
import numpy as np
np.set_printoptions(precision=2)
@ -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)
@ -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)