Menu

[r4657]: / trunk / py4science / examples / faces / test_imatch.py  Maximize  Restore  History

Download this file

63 lines (48 with data), 1.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
"""Basic tests for imatch package."""
# Stdlib modules
import os
import unittest
# Third-party
import numpy as N
import numpy.testing as NT
# Our own code
import imatch
reload(imatch) # for interactive testing
# Temp - for interactive debugging
from IPython.Shell import IPShellEmbed; ipshell = IPShellEmbed()
# Testing classes start
class ImageCollectionTestCase(unittest.TestCase):
def test(self):
"Simple test to call on a correct image dir"
dirname = 'data_train'
images = imatch.ImageCollection.from_directory(dirname)
# This directory only contains true image files
self.assert_(images.num_images == len(os.listdir(dirname)))
class TrainingImagesTestCase(unittest.TestCase):
def test(self):
"Simple test to call on a correct image dir"
dirname = 'data_train'
images = imatch.TrainingImages(dirname)
# Execution as a script
# Select here if you only want to see a few tests.
run_all = True
run_only = []
if __name__ == '__main__':
print __doc__
runner = unittest.TextTestRunner()
if run_all:
print 'Running all tests.\n'
# Load ourselves, and load all tests which conform to standard
# unittest naming conventions
import test_imatch
u_tests = unittest.defaultTestLoader.loadTestsFromModule(test_imatch)
# Define a global suite with all tests to be run
all_tests = unittest.TestSuite([u_tests])
runner.run(all_tests)
else:
print 'Running only selected tests.\n'
for test in run_only:
print 'Running test:',test
print test.shortDescription()
runner.run(test)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.