Commit e58de551 authored by Andrey Morozov's avatar Andrey Morozov

corrected the errors in the python's tests

parent 7e2f7719
...@@ -845,7 +845,7 @@ class FunctionTests(OpenCVTests): ...@@ -845,7 +845,7 @@ class FunctionTests(OpenCVTests):
self.assertEqual(cv.Sum(M)[0], r * c) self.assertEqual(cv.Sum(M)[0], r * c)
def test_Threshold(self): def test_Threshold(self):
""" directed test for bug 2790622 """ #""" directed test for bug 2790622 """
src = self.get_sample("samples/c/lena.jpg", 0) src = self.get_sample("samples/c/lena.jpg", 0)
results = set() results = set()
for i in range(10): for i in range(10):
...@@ -963,7 +963,7 @@ class AreaTests(OpenCVTests): ...@@ -963,7 +963,7 @@ class AreaTests(OpenCVTests):
rvec[1,0] = 1 rvec[1,0] = 1
rvec[2,0] = 1 rvec[2,0] = 1
cv.Rodrigues2(rvec, m[:3,:3]) cv.Rodrigues2(rvec, m[:3,:3])
print m #print m
else: else:
print "SKIPPING test_numpy - numpy support not built" print "SKIPPING test_numpy - numpy support not built"
...@@ -1039,11 +1039,11 @@ class AreaTests(OpenCVTests): ...@@ -1039,11 +1039,11 @@ class AreaTests(OpenCVTests):
cvm = cv.CreateMat(20, 10, cv.CV_32FC1) cvm = cv.CreateMat(20, 10, cv.CV_32FC1)
def test_depths(self): def test_depths(self):
""" Make sure that the depth enums are unique """ #""" Make sure that the depth enums are unique """
self.assert_(len(self.depths) == len(set(self.depths))) self.assert_(len(self.depths) == len(set(self.depths)))
def test_leak(self): def test_leak(self):
""" If CreateImage is not releasing image storage, then the loop below should use ~4GB of memory. """ #""" If CreateImage is not releasing image storage, then the loop below should use ~4GB of memory. """
for i in range(64000): for i in range(64000):
a = cv.CreateImage((1024,1024), cv.IPL_DEPTH_8U, 1) a = cv.CreateImage((1024,1024), cv.IPL_DEPTH_8U, 1)
for i in range(64000): for i in range(64000):
...@@ -1768,7 +1768,7 @@ class AreaTests(OpenCVTests): ...@@ -1768,7 +1768,7 @@ class AreaTests(OpenCVTests):
#self.snap(img) #self.snap(img)
def test_create(self): def test_create(self):
""" CvCreateImage, CvCreateMat and the header-only form """ #""" CvCreateImage, CvCreateMat and the header-only form """
for (w,h) in [ (320,400), (640,480), (1024, 768) ]: for (w,h) in [ (320,400), (640,480), (1024, 768) ]:
data = "z" * (w * h) data = "z" * (w * h)
...@@ -2084,7 +2084,7 @@ class AreaTests(OpenCVTests): ...@@ -2084,7 +2084,7 @@ class AreaTests(OpenCVTests):
print mat print mat
def test_rand_PutText(self): def test_rand_PutText(self):
""" Test for bug 2829336 """ #""" Test for bug 2829336 """
mat = cv.CreateMat( 64, 64, cv.CV_8UC1) mat = cv.CreateMat( 64, 64, cv.CV_8UC1)
font = cv.InitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1) font = cv.InitFont(cv.CV_FONT_HERSHEY_SIMPLEX, 1, 1)
cv.PutText(mat, chr(127), (20, 20), font, 255) cv.PutText(mat, chr(127), (20, 20), font, 255)
...@@ -2145,32 +2145,33 @@ class NewTests(OpenCVTests): ...@@ -2145,32 +2145,33 @@ class NewTests(OpenCVTests):
if __name__ == '__main__': if __name__ == '__main__':
print "testing", cv.__version__ print "testing", cv.__version__
random.seed(0) random.seed(0)
optlist, args = getopt.getopt(sys.argv[1:], 'l:rd') unittest.main()
loops = 1 # optlist, args = getopt.getopt(sys.argv[1:], 'l:rd')
shuffle = 0 # loops = 1
doc_frags = False # shuffle = 0
for o,a in optlist: # doc_frags = False
if o == '-l': # for o,a in optlist:
loops = int(a) # if o == '-l':
if o == '-r': # loops = int(a)
shuffle = 1 # if o == '-r':
if o == '-d': # shuffle = 1
doc_frags = True # if o == '-d':
# doc_frags = True
cases = [PreliminaryTests, FunctionTests, AreaTests] #
if doc_frags: # cases = [PreliminaryTests, FunctionTests, AreaTests]
cases += [DocumentFragmentTests] # if doc_frags:
everything = [(tc, t) for tc in cases for t in unittest.TestLoader().getTestCaseNames(tc) ] # cases += [DocumentFragmentTests]
if len(args) == 0: # everything = [(tc, t) for tc in cases for t in unittest.TestLoader().getTestCaseNames(tc) ]
# cases = [NewTests] # if len(args) == 0:
args = everything # # cases = [NewTests]
else: # args = everything
args = [(tc, t) for (tc, t) in everything if t in args] # else:
# args = [(tc, t) for (tc, t) in everything if t in args]
suite = unittest.TestSuite() #
for l in range(loops): # suite = unittest.TestSuite()
if shuffle: # for l in range(loops):
random.shuffle(args) # if shuffle:
for tc,t in args: # random.shuffle(args)
suite.addTest(tc(t)) # for tc,t in args:
unittest.TextTestRunner(verbosity=2).run(suite) # suite.addTest(tc(t))
# unittest.TextTestRunner(verbosity=2).run(suite)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment