Adds Ant usage for compilation and to run all tests at once.

TODO : 
Find how to generate doc using Ant. 

Signed-off-by: Julien Lengrand-Lambert <julien@lengrandlambert.fr>
This commit is contained in:
Julien Lengrand-Lambert
2011-12-05 21:58:48 +01:00
parent 04457c2311
commit dafc526277
4 changed files with 41 additions and 15 deletions

27
build.xml Normal file
View File

@@ -0,0 +1,27 @@
<project name="Tippy" default="tests" basedir=".">
<taskdef resource="pyAntTasks.properties"/>
<property name="src.dir" value="tippy"/>
<property name="ex.dir" value="tippy/examples"/>
<property name="tests.dir" value="tippy/tests"/>
<target name="compile all">
<py-compile dir="${src.dir}" pythonpath="${src.dir}" optimize="0"/>
</target>
<target name="compile examples">
<py-compile dir="${ex.dir}" pythonpath="${ex.dir}" optimize="0"/>
</target>
<target name="compile tests">
<py-compile dir="${tests.dir}" pythonpath="${tests.dir}" optimize="0"/>
</target>
<target name="tests">
<py-test pythonpath="." dir="${src.dir}">
<fileset dir="${src.dir}">
<include name="*/test_*"/>
</fileset>
</py-test>
</target>
</project>

View File

@@ -7,11 +7,11 @@ Created on Nov 19, 2011
@email: julien@lengrand.fr
'''
import cv
import tippy.basic_operations as bo
import unittest
import tippy.basic_operations as bo
class Test(unittest.TestCase):
"""
The class inherits from unittest
@@ -20,8 +20,8 @@ class Test(unittest.TestCase):
"""
This method is called before each test
"""
self.img_1c = cv.LoadImage("../data/tippy.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
self.img_3c = cv.LoadImage("../data/tippy.jpg", cv.CV_LOAD_IMAGE_COLOR) # 3 channel image
self.img_1c = cv.LoadImage("data/tippy.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
self.img_3c = cv.LoadImage("data/tippy.jpg", cv.CV_LOAD_IMAGE_COLOR) # 3 channel image
self.img_fake_2c = cv.CreateImage((15, 15), cv.IPL_DEPTH_8U, 2) # 2 channels
self.fake_img = 10 # non Image
@@ -44,15 +44,15 @@ class Test(unittest.TestCase):
self.assertEqual(img.depth, out_img.depth)
self.assertEqual(cv.GetSize(img), cv.GetSize(out_img))
self.assertRaises(TypeError, lambda: bo.create_same_image(self.fake_img))
def test_mouse_point(self):
# img test
self.assertRaises(TypeError, lambda: bo.mouse_point(self.fake_img))
# name test
self.assertRaises(TypeError, lambda: bo.mouse_point(self.fake_name))
self.assertRaises(TypeError, lambda: bo.mouse_point(self.img_3c, self.fake_name))
# mode test
self.assertRaises(TypeError, lambda: bo.mouse_point(self.fake_mode))
self.assertRaises(ValueError, lambda: bo.mouse_point(self.false_mode))
self.assertRaises(TypeError, lambda: bo.mouse_point(self.img_3c, mode=self.fake_mode))
self.assertRaises(ValueError, lambda: bo.mouse_point(self.img_3c, mode=self.false_mode))
# TODO: How to test arguments that need user interaction?
#if __name__ == "__main__":

View File

@@ -8,6 +8,7 @@ Created on Nov 24, 2011
'''
import unittest
import cv
import tippy.display_operations as do
class Test(unittest.TestCase):
@@ -18,7 +19,7 @@ class Test(unittest.TestCase):
"""
This method is called before each test
"""
self.img = cv.LoadImage("../data/tippy.jpg", cv.CV_LOAD_IMAGE_COLOR) # 3 channel image
self.img = cv.LoadImage("data/tippy.jpg", cv.CV_LOAD_IMAGE_COLOR) # 3 channel image
self.fake_img = 10 # non Image
def tearDown(self):

View File

@@ -10,14 +10,12 @@ import cv
import tippy.segmentations as se
class Test(unittest.TestCase):
def setUp(self):
"""
This method is called before each test
"""
self.img_1c = cv.LoadImage("../data/tippy.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
self.img_3c = cv.LoadImage("../data/tippy.jpg", cv.CV_LOAD_IMAGE_COLOR) # 3 channel image
self.img_1c = cv.LoadImage("data/tippy.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
self.img_3c = cv.LoadImage("data/tippy.jpg", cv.CV_LOAD_IMAGE_COLOR) # 3 channel image
self.img_16s = cv.CreateImage((15, 15), cv.IPL_DEPTH_16S, 1) # Non 8 bits image
self.fake_img = 10 # non Image
@@ -70,11 +68,11 @@ class Test(unittest.TestCase):
self.assertRaises(ValueError, lambda: se.simple_region_growing(self.img_1c, self.seed, self.thres, self.other_conn))
# function result tests
# 4-conn
img_gnu = cv.LoadImage("../data/gnu.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
img_gnu = cv.LoadImage("data/gnu.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
out_img = se.simple_region_growing(img_gnu, seed=(70, 106), threshold=20)
self.assertEqual(cv.CountNonZero(out_img), 584)
# 8-conn
img_gnu = cv.LoadImage("../data/gnu.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
img_gnu = cv.LoadImage("data/gnu.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE) # 1 channel image
out_img = se.simple_region_growing(img_gnu, seed=(70, 106), threshold=20, conn=8)
self.assertEqual(cv.CountNonZero(out_img), 627)