From 7eb098d20680d28d8fbe05a8cd2dd22a265c4786 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Fri, 13 Dec 2013 10:21:00 +0100 Subject: [PATCH] Simplify test organization --- MANIFEST.in | 2 +- xbob/io/{test => }/data/img_indexed_color.png | Bin xbob/io/{test => }/data/matlab_1d.hdf5 | Bin xbob/io/{test => }/data/matlab_2d.hdf5 | Bin xbob/io/{test => }/data/test.jpg | Bin xbob/io/{test => }/data/test.mat | Bin xbob/io/{test => }/data/test.mov | Bin xbob/io/{test => }/data/test.pbm | 0 xbob/io/{test => }/data/test.pgm | Bin xbob/io/{test => }/data/test.ppm | Bin xbob/io/{test => }/data/test1.hdf5 | Bin xbob/io/{test => }/data/test7_unlimited.hdf5 | Bin xbob/io/{test => }/data/test_1d.mat | Bin xbob/io/{test => }/data/test_1d_cplx.mat | Bin xbob/io/{test => }/data/test_2d.mat | Bin xbob/io/{test => }/data/test_2d_cplx.mat | Bin xbob/io/{test => }/data/test_3d.mat | Bin xbob/io/{test => }/data/test_3d_cplx.mat | Bin xbob/io/{test => }/data/test_4d.mat | Bin xbob/io/{test => }/data/test_4d_cplx.mat | Bin xbob/io/{test => }/data/test_array_codec.txt | 0 xbob/io/{test => }/data/test_cell.mat | Bin xbob/io/{test => }/data/test_h264.mov | Bin xbob/io/{test => }/data/torch.tensor | Bin xbob/io/{test => }/data/torch3.bindata | Bin xbob/io/script/video_test.py | 2 +- xbob/io/test/__init__.py | 0 xbob/io/{test => }/test_file.py | 99 +++++++++--------- xbob/io/{test => }/test_hdf5.py | 39 ++++--- xbob/io/{test => }/test_image.py | 5 +- xbob/io/{test/utils.py => test_utils.py} | 8 +- xbob/io/{test => }/test_video.py | 66 ++++++------ xbob/io/{test => }/test_video_codec.py | 28 ++--- 33 files changed, 123 insertions(+), 126 deletions(-) rename xbob/io/{test => }/data/img_indexed_color.png (100%) rename xbob/io/{test => }/data/matlab_1d.hdf5 (100%) rename xbob/io/{test => }/data/matlab_2d.hdf5 (100%) rename xbob/io/{test => }/data/test.jpg (100%) rename xbob/io/{test => }/data/test.mat (100%) rename xbob/io/{test => }/data/test.mov (100%) rename xbob/io/{test => }/data/test.pbm (100%) rename xbob/io/{test => }/data/test.pgm (100%) rename xbob/io/{test => }/data/test.ppm (100%) rename xbob/io/{test => }/data/test1.hdf5 (100%) rename xbob/io/{test => }/data/test7_unlimited.hdf5 (100%) rename xbob/io/{test => }/data/test_1d.mat (100%) rename xbob/io/{test => }/data/test_1d_cplx.mat (100%) rename xbob/io/{test => }/data/test_2d.mat (100%) rename xbob/io/{test => }/data/test_2d_cplx.mat (100%) rename xbob/io/{test => }/data/test_3d.mat (100%) rename xbob/io/{test => }/data/test_3d_cplx.mat (100%) rename xbob/io/{test => }/data/test_4d.mat (100%) rename xbob/io/{test => }/data/test_4d_cplx.mat (100%) rename xbob/io/{test => }/data/test_array_codec.txt (100%) rename xbob/io/{test => }/data/test_cell.mat (100%) rename xbob/io/{test => }/data/test_h264.mov (100%) rename xbob/io/{test => }/data/torch.tensor (100%) rename xbob/io/{test => }/data/torch3.bindata (100%) delete mode 100644 xbob/io/test/__init__.py rename xbob/io/{test => }/test_file.py (77%) rename xbob/io/{test => }/test_hdf5.py (92%) rename xbob/io/{test => }/test_image.py (89%) rename xbob/io/{test/utils.py => test_utils.py} (96%) rename xbob/io/{test => }/test_video.py (82%) rename xbob/io/{test => }/test_video_codec.py (91%) diff --git a/MANIFEST.in b/MANIFEST.in index d4fcb40..9880b57 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include LICENSE README.rst bootstrap.py buildout.cfg recursive-include doc conf.py *.rst recursive-include xbob *.cpp *.h -recursive-include xbob/io/test/data *.* +recursive-include xbob/io/data *.* recursive-include xbob/io/fonts *.txt *.ttf diff --git a/xbob/io/test/data/img_indexed_color.png b/xbob/io/data/img_indexed_color.png similarity index 100% rename from xbob/io/test/data/img_indexed_color.png rename to xbob/io/data/img_indexed_color.png diff --git a/xbob/io/test/data/matlab_1d.hdf5 b/xbob/io/data/matlab_1d.hdf5 similarity index 100% rename from xbob/io/test/data/matlab_1d.hdf5 rename to xbob/io/data/matlab_1d.hdf5 diff --git a/xbob/io/test/data/matlab_2d.hdf5 b/xbob/io/data/matlab_2d.hdf5 similarity index 100% rename from xbob/io/test/data/matlab_2d.hdf5 rename to xbob/io/data/matlab_2d.hdf5 diff --git a/xbob/io/test/data/test.jpg b/xbob/io/data/test.jpg similarity index 100% rename from xbob/io/test/data/test.jpg rename to xbob/io/data/test.jpg diff --git a/xbob/io/test/data/test.mat b/xbob/io/data/test.mat similarity index 100% rename from xbob/io/test/data/test.mat rename to xbob/io/data/test.mat diff --git a/xbob/io/test/data/test.mov b/xbob/io/data/test.mov similarity index 100% rename from xbob/io/test/data/test.mov rename to xbob/io/data/test.mov diff --git a/xbob/io/test/data/test.pbm b/xbob/io/data/test.pbm similarity index 100% rename from xbob/io/test/data/test.pbm rename to xbob/io/data/test.pbm diff --git a/xbob/io/test/data/test.pgm b/xbob/io/data/test.pgm similarity index 100% rename from xbob/io/test/data/test.pgm rename to xbob/io/data/test.pgm diff --git a/xbob/io/test/data/test.ppm b/xbob/io/data/test.ppm similarity index 100% rename from xbob/io/test/data/test.ppm rename to xbob/io/data/test.ppm diff --git a/xbob/io/test/data/test1.hdf5 b/xbob/io/data/test1.hdf5 similarity index 100% rename from xbob/io/test/data/test1.hdf5 rename to xbob/io/data/test1.hdf5 diff --git a/xbob/io/test/data/test7_unlimited.hdf5 b/xbob/io/data/test7_unlimited.hdf5 similarity index 100% rename from xbob/io/test/data/test7_unlimited.hdf5 rename to xbob/io/data/test7_unlimited.hdf5 diff --git a/xbob/io/test/data/test_1d.mat b/xbob/io/data/test_1d.mat similarity index 100% rename from xbob/io/test/data/test_1d.mat rename to xbob/io/data/test_1d.mat diff --git a/xbob/io/test/data/test_1d_cplx.mat b/xbob/io/data/test_1d_cplx.mat similarity index 100% rename from xbob/io/test/data/test_1d_cplx.mat rename to xbob/io/data/test_1d_cplx.mat diff --git a/xbob/io/test/data/test_2d.mat b/xbob/io/data/test_2d.mat similarity index 100% rename from xbob/io/test/data/test_2d.mat rename to xbob/io/data/test_2d.mat diff --git a/xbob/io/test/data/test_2d_cplx.mat b/xbob/io/data/test_2d_cplx.mat similarity index 100% rename from xbob/io/test/data/test_2d_cplx.mat rename to xbob/io/data/test_2d_cplx.mat diff --git a/xbob/io/test/data/test_3d.mat b/xbob/io/data/test_3d.mat similarity index 100% rename from xbob/io/test/data/test_3d.mat rename to xbob/io/data/test_3d.mat diff --git a/xbob/io/test/data/test_3d_cplx.mat b/xbob/io/data/test_3d_cplx.mat similarity index 100% rename from xbob/io/test/data/test_3d_cplx.mat rename to xbob/io/data/test_3d_cplx.mat diff --git a/xbob/io/test/data/test_4d.mat b/xbob/io/data/test_4d.mat similarity index 100% rename from xbob/io/test/data/test_4d.mat rename to xbob/io/data/test_4d.mat diff --git a/xbob/io/test/data/test_4d_cplx.mat b/xbob/io/data/test_4d_cplx.mat similarity index 100% rename from xbob/io/test/data/test_4d_cplx.mat rename to xbob/io/data/test_4d_cplx.mat diff --git a/xbob/io/test/data/test_array_codec.txt b/xbob/io/data/test_array_codec.txt similarity index 100% rename from xbob/io/test/data/test_array_codec.txt rename to xbob/io/data/test_array_codec.txt diff --git a/xbob/io/test/data/test_cell.mat b/xbob/io/data/test_cell.mat similarity index 100% rename from xbob/io/test/data/test_cell.mat rename to xbob/io/data/test_cell.mat diff --git a/xbob/io/test/data/test_h264.mov b/xbob/io/data/test_h264.mov similarity index 100% rename from xbob/io/test/data/test_h264.mov rename to xbob/io/data/test_h264.mov diff --git a/xbob/io/test/data/torch.tensor b/xbob/io/data/torch.tensor similarity index 100% rename from xbob/io/test/data/torch.tensor rename to xbob/io/data/torch.tensor diff --git a/xbob/io/test/data/torch3.bindata b/xbob/io/data/torch3.bindata similarity index 100% rename from xbob/io/test/data/torch3.bindata rename to xbob/io/data/torch3.bindata diff --git a/xbob/io/script/video_test.py b/xbob/io/script/video_test.py index d2bd754..2eda5f3 100644 --- a/xbob/io/script/video_test.py +++ b/xbob/io/script/video_test.py @@ -25,7 +25,7 @@ import numpy # internal from .. import utils, create_directories_save from .. import save as save_to_file -from ..test import utils as test_utils +from .. import test_utils def list_codecs(*args, **kwargs): diff --git a/xbob/io/test/__init__.py b/xbob/io/test/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/xbob/io/test/test_file.py b/xbob/io/test_file.py similarity index 77% rename from xbob/io/test/test_file.py rename to xbob/io/test_file.py index f55e4c7..837b37b 100644 --- a/xbob/io/test/test_file.py +++ b/xbob/io/test_file.py @@ -14,18 +14,17 @@ import sys import numpy import nose.tools -from .. import load, write, peek, peek_all, File -from . import utils as testutils +from . import load, write, peek, peek_all, File, test_utils def test_peek(): - - f = testutils.datafile('test1.hdf5', __name__) + + f = test_utils.datafile('test1.hdf5', __name__) assert peek(f) == (numpy.uint16, (3,), (1,)) assert peek_all(f) == (numpy.uint16, (3,3), (3,1)) def test_iteration(): - - fname = testutils.datafile('matlab_2d.hdf5', __name__) + + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') nose.tools.eq_(len(f), 512) @@ -35,8 +34,8 @@ def test_iteration(): assert numpy.allclose(l, i) def test_indexing(): - - fname = testutils.datafile('matlab_2d.hdf5', __name__) + + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') nose.tools.eq_(len(f), 512) @@ -51,7 +50,7 @@ def test_indexing(): def test_slicing_empty(): - fname = testutils.datafile('matlab_2d.hdf5', __name__) + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') objs = f[1:1] @@ -59,7 +58,7 @@ def test_slicing_empty(): def test_slicing_0(): - fname = testutils.datafile('matlab_2d.hdf5', __name__) + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') objs = f[:] @@ -68,7 +67,7 @@ def test_slicing_0(): def test_slicing_1(): - fname = testutils.datafile('matlab_2d.hdf5', __name__) + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') # get slice @@ -81,7 +80,7 @@ def test_slicing_1(): def test_slicing_2(): - fname = testutils.datafile('matlab_2d.hdf5', __name__) + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') # get negative slicing @@ -93,7 +92,7 @@ def test_slicing_2(): def test_slicing_3(): - fname = testutils.datafile('matlab_2d.hdf5', __name__) + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') # get negative stepping slice @@ -106,7 +105,7 @@ def test_slicing_3(): def test_slicing_4(): - fname = testutils.datafile('matlab_2d.hdf5', __name__) + fname = test_utils.datafile('matlab_2d.hdf5', __name__) f = File(fname, 'r') # get all negative slice @@ -119,28 +118,28 @@ def test_slicing_4(): @nose.tools.raises(TypeError) def test_indexing_type_check(): - - f = File(testutils.datafile('matlab_2d.hdf5', __name__), 'r') + + f = File(test_utils.datafile('matlab_2d.hdf5', __name__), 'r') nose.tools.eq_(len(f), 512) f[4.5] @nose.tools.raises(IndexError) def test_indexing_boundaries(): - - f = File(testutils.datafile('matlab_2d.hdf5', __name__), 'r') + + f = File(test_utils.datafile('matlab_2d.hdf5', __name__), 'r') nose.tools.eq_(len(f), 512) f[512] @nose.tools.raises(IndexError) def test_indexing_negative_boundaries(): - f = File(testutils.datafile('matlab_2d.hdf5', __name__), 'r') + f = File(test_utils.datafile('matlab_2d.hdf5', __name__), 'r') nose.tools.eq_(len(f), 512) f[-513] def transcode(filename): """Runs a complete transcoding test, to and from the binary format.""" - tmpname = testutils.temporary_filename(suffix=os.path.splitext(filename)[1]) + tmpname = test_utils.temporary_filename(suffix=os.path.splitext(filename)[1]) try: # transcode from test format into the test format -- test array access modes @@ -171,7 +170,7 @@ def transcode(filename): def array_readwrite(extension, arr, close=False): """Runs a read/write verify step using the given numpy data""" - tmpname = testutils.temporary_filename(suffix=extension) + tmpname = test_utils.temporary_filename(suffix=extension) try: write(arr, tmpname) reloaded = load(tmpname) @@ -182,7 +181,7 @@ def array_readwrite(extension, arr, close=False): def arrayset_readwrite(extension, arrays, close=False): """Runs a read/write verify step using the given numpy data""" - tmpname = testutils.temporary_filename(suffix=extension) + tmpname = test_utils.temporary_filename(suffix=extension) try: f = File(tmpname, 'w') for k in arrays: @@ -227,11 +226,11 @@ def test_hdf5(): arrayset_readwrite(".h5", a4) # complete transcoding tests - transcode(testutils.datafile('test1.hdf5', __name__)) - transcode(testutils.datafile('matlab_1d.hdf5', __name__)) - transcode(testutils.datafile('matlab_2d.hdf5', __name__)) + transcode(test_utils.datafile('test1.hdf5', __name__)) + transcode(test_utils.datafile('matlab_1d.hdf5', __name__)) + transcode(test_utils.datafile('matlab_2d.hdf5', __name__)) -@testutils.extension_available('.bindata') +@test_utils.extension_available('.bindata') def test_torch3_binary(): # array writing tests @@ -262,9 +261,9 @@ def test_torch3_binary(): nose.tools.assert_raises(RuntimeError, arrayset_readwrite, ".bindata", a4) # complete transcoding test - transcode(testutils.datafile('torch3.bindata', __name__)) + transcode(test_utils.datafile('torch3.bindata', __name__)) -@testutils.extension_available('.mat') +@test_utils.extension_available('.mat') def test_mat_file_io(): # array writing tests @@ -295,23 +294,23 @@ def test_mat_file_io(): arrayset_readwrite(".mat", a4) # complete transcoding tests - transcode(testutils.datafile('test_1d.mat', __name__)) #pseudo 1D - matlab does not support true 1D - transcode(testutils.datafile('test_2d.mat', __name__)) - transcode(testutils.datafile('test_3d.mat', __name__)) - transcode(testutils.datafile('test_4d.mat', __name__)) - transcode(testutils.datafile('test_1d_cplx.mat', __name__)) #pseudo 1D - matlab does not support 1D - transcode(testutils.datafile('test_2d_cplx.mat', __name__)) - transcode(testutils.datafile('test_3d_cplx.mat', __name__)) - transcode(testutils.datafile('test_4d_cplx.mat', __name__)) - transcode(testutils.datafile('test.mat', __name__)) #3D complex, large + transcode(test_utils.datafile('test_1d.mat', __name__)) #pseudo 1D - matlab does not support true 1D + transcode(test_utils.datafile('test_2d.mat', __name__)) + transcode(test_utils.datafile('test_3d.mat', __name__)) + transcode(test_utils.datafile('test_4d.mat', __name__)) + transcode(test_utils.datafile('test_1d_cplx.mat', __name__)) #pseudo 1D - matlab does not support 1D + transcode(test_utils.datafile('test_2d_cplx.mat', __name__)) + transcode(test_utils.datafile('test_3d_cplx.mat', __name__)) + transcode(test_utils.datafile('test_4d_cplx.mat', __name__)) + transcode(test_utils.datafile('test.mat', __name__)) #3D complex, large @nose.tools.nottest -@testutils.extension_available('.mat') +@test_utils.extension_available('.mat') def test_mat_file_io_does_not_crash(): - data = load(testutils.datafile('test_cell.mat', __name__)) + data = load(test_utils.datafile('test_cell.mat', __name__)) -@testutils.extension_available('.tensor') +@test_utils.extension_available('.tensor') def test_tensorfile(): # array writing tests @@ -337,16 +336,16 @@ def test_tensorfile(): arrayset_readwrite(".tensor", a3) # complete transcoding test - transcode(testutils.datafile('torch.tensor', __name__)) + transcode(test_utils.datafile('torch.tensor', __name__)) -@testutils.extension_available('.pgm') -@testutils.extension_available('.pbm') -@testutils.extension_available('.ppm') +@test_utils.extension_available('.pgm') +@test_utils.extension_available('.pbm') +@test_utils.extension_available('.ppm') def test_netpbm(): def image_transcode(filename): - tmpname = testutils.temporary_filename(suffix=os.path.splitext(filename)[1]) + tmpname = test_utils.temporary_filename(suffix=os.path.splitext(filename)[1]) try: # complete transcoding test @@ -363,12 +362,12 @@ def test_netpbm(): finally: if os.path.exists(tmpname): os.unlink(tmpname) - image_transcode(testutils.datafile('test.pgm', __name__)) #indexed, works fine - image_transcode(testutils.datafile('test.pbm', __name__)) #indexed, works fine - image_transcode(testutils.datafile('test.ppm', __name__)) #indexed, works fine - #image_transcode(testutils.datafile('test.jpg', __name__)) #does not work because of re-compression + image_transcode(test_utils.datafile('test.pgm', __name__)) #indexed, works fine + image_transcode(test_utils.datafile('test.pbm', __name__)) #indexed, works fine + image_transcode(test_utils.datafile('test.ppm', __name__)) #indexed, works fine + #image_transcode(test_utils.datafile('test.jpg', __name__)) #does not work because of re-compression -@testutils.extension_available('.csv') +@test_utils.extension_available('.csv') def test_csv(): # array writing tests diff --git a/xbob/io/test/test_hdf5.py b/xbob/io/test_hdf5.py similarity index 92% rename from xbob/io/test/test_hdf5.py rename to xbob/io/test_hdf5.py index df47329..084c7c6 100644 --- a/xbob/io/test/test_hdf5.py +++ b/xbob/io/test_hdf5.py @@ -26,8 +26,7 @@ import numpy import random import nose.tools -from .. import HDF5File, load, save, peek_all -from . import utils as testutils +from . import HDF5File, load, save, peek_all, test_utils def read_write_check(outfile, dname, data, dtype=None): """Tests scalar input/output on HDF5 files""" @@ -93,7 +92,7 @@ def test_can_create(): # Now we create a new binary output file in a temporary location and save # the data there. - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') outfile.append('testdata', arrays) @@ -147,7 +146,7 @@ def test_type_support(): N = 100 - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') data = [bool(int(random.uniform(0,2))) for z in range(N)] @@ -215,7 +214,7 @@ def test_dataset_management(): # Let's just create some dummy data to play with N = 100 - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') data = [int(random.uniform(0,N)) for z in range(N)] @@ -258,7 +257,7 @@ def test_resize_and_preserve(): array = numpy.array(data, 'int32').reshape(SHAPE) # Try to save a slice - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() save(array[:,0], tmpname) finally: @@ -269,42 +268,42 @@ def test_can_load_hdf5_from_matlab(): # shows we can load a 2D matlab array and interpret it as a bunch of 1D # arrays, correctly - t = load(testutils.datafile('matlab_1d.hdf5', __name__)) + t = load(test_utils.datafile('matlab_1d.hdf5', __name__)) nose.tools.eq_(t.shape, (512,)) nose.tools.eq_(t.dtype, numpy.float64) - t = load(testutils.datafile('matlab_2d.hdf5', __name__)) + t = load(test_utils.datafile('matlab_2d.hdf5', __name__)) nose.tools.eq_(t.shape, (512, 2)) nose.tools.eq_(t.dtype, numpy.float64) # interestingly enough, if you load those files as arrays, you will read # the whole data at once: - dtype, shape, stride = peek_all(testutils.datafile('matlab_1d.hdf5', __name__)) + dtype, shape, stride = peek_all(test_utils.datafile('matlab_1d.hdf5', __name__)) nose.tools.eq_(shape, (512,)) nose.tools.eq_(dtype, numpy.dtype('float64')) - dtype, shape, stride = peek_all(testutils.datafile('matlab_2d.hdf5', __name__)) + dtype, shape, stride = peek_all(test_utils.datafile('matlab_2d.hdf5', __name__)) nose.tools.eq_(shape, (512, 2)) nose.tools.eq_(dtype, numpy.dtype('float64')) def test_matlab_import(): # This test verifies we can import HDF5 datasets generated in Matlab - mfile = HDF5File(testutils.datafile('matlab_1d.hdf5', __name__)) + mfile = HDF5File(test_utils.datafile('matlab_1d.hdf5', __name__)) nose.tools.eq_(mfile.paths(), ('/array',)) def test_ioload_unlimited(): # This test verifies that a 3D array whose first dimension is unlimited # and size equal to 1 can be read as a 2D array - mfile = load(testutils.datafile('test7_unlimited.hdf5', __name__)) + mfile = load(test_utils.datafile('test7_unlimited.hdf5', __name__)) nose.tools.eq_(mfile.ndim, 2) def test_attribute_version(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') outfile.set_attribute('version', 32) nose.tools.eq_(outfile.get_attribute('version'), 32) @@ -315,7 +314,7 @@ def test_attribute_version(): def test_string_support(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') attribute = 'this is my long test string with \nNew lines' outfile.set('string', attribute) @@ -329,7 +328,7 @@ def test_string_support(): def test_string_attribute_support(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') attribute = 'this is my long test string with \nNew lines' outfile.set_attribute('string', attribute) @@ -348,7 +347,7 @@ def test_string_attribute_support(): def test_can_use_set_with_iterables(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') data = [1, 34.5, True] outfile.set('data', data) @@ -360,7 +359,7 @@ def test_can_use_set_with_iterables(): def test_has_attribute(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') i = 35 f = 3.14 @@ -377,7 +376,7 @@ def test_has_attribute(): def test_get_attributes(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') nothing = outfile.get_attributes() nose.tools.eq_(len(nothing), 0) @@ -397,7 +396,7 @@ def test_set_compression(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') data = numpy.random.random((50,50)) outfile.set('data', data, compression=9) @@ -413,7 +412,7 @@ def test_append_compression(): try: - tmpname = testutils.temporary_filename() + tmpname = test_utils.temporary_filename() outfile = HDF5File(tmpname, 'w') data = numpy.random.random((50,50)) for k in range(len(data)): outfile.append('data', data[k], compression=9) diff --git a/xbob/io/test/test_image.py b/xbob/io/test_image.py similarity index 89% rename from xbob/io/test/test_image.py rename to xbob/io/test_image.py index 5d3dc24..aa5542d 100644 --- a/xbob/io/test/test_image.py +++ b/xbob/io/test_image.py @@ -20,15 +20,14 @@ """Runs some image tests """ -from . import utils as testutils +from . import load, test_utils # These are some global parameters for the test. -PNG_INDEXED_COLOR = testutils.datafile('img_indexed_color.png', __name__) +PNG_INDEXED_COLOR = test_utils.datafile('img_indexed_color.png', __name__) def test_png_indexed_color(): # Read an indexed color PNG image, and compared with hardcoded values - from .. import load img = load(PNG_INDEXED_COLOR) assert img.shape == (3,22,32) assert img[0,0,0] == 255 diff --git a/xbob/io/test/utils.py b/xbob/io/test_utils.py similarity index 96% rename from xbob/io/test/utils.py rename to xbob/io/test_utils.py index 0ec99af..f8e996b 100644 --- a/xbob/io/test/utils.py +++ b/xbob/io/test_utils.py @@ -70,7 +70,7 @@ def ffmpeg_version_lessthan(v): '''Returns true if the version of ffmpeg compiled-in is at least the version indicated as a string parameter.''' - from .._externals import versions + from ._externals import versions if versions['FFmpeg']['ffmpeg'] == 'unavailable': return False avcodec_inst= SV(versions['FFmpeg']['avcodec']) avcodec_req = ffmpeg_versions[v][0] @@ -101,7 +101,7 @@ def ffmpeg_found(version_geq=None): @functools.wraps(test) def wrapper(*args, **kwargs): try: - from .._externals import versions + from ._externals import versions avcodec_inst = SV(versions['FFmpeg']['avcodec']) avformat_inst = SV(versions['FFmpeg']['avformat']) avutil_inst = SV(versions['FFmpeg']['avutil']) @@ -124,7 +124,7 @@ def codec_available(codec): @functools.wraps(test) def wrapper(*args, **kwargs): - from ..io import supported_video_codecs + from ._externals import supported_video_codecs d = supported_video_codecs() if codec in d and d[codec]['encode'] and d[codec]['decode']: return test(*args, **kwargs) @@ -142,7 +142,7 @@ def extension_available(extension): @functools.wraps(test) def wrapper(*args, **kwargs): - from .._externals import extensions + from ._externals import extensions if extension in extensions(): return test(*args, **kwargs) else: diff --git a/xbob/io/test/test_video.py b/xbob/io/test_video.py similarity index 82% rename from xbob/io/test/test_video.py rename to xbob/io/test_video.py index 27d6416..29b0ccd 100644 --- a/xbob/io/test/test_video.py +++ b/xbob/io/test_video.py @@ -10,16 +10,16 @@ import numpy import nose.tools -from . import utils as testutils +from . import test_utils # These are some global parameters for the test. -INPUT_VIDEO = testutils.datafile('test.mov', __name__) +INPUT_VIDEO = test_utils.datafile('test.mov', __name__) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_codec_support(): # Describes all encoders - from .._externals import describe_encoder, describe_decoder, supported_video_codecs + from ._externals import describe_encoder, describe_decoder, supported_video_codecs supported = supported_video_codecs() @@ -34,11 +34,11 @@ def test_codec_support(): assert supported[codec]['encode'] assert supported[codec]['decode'] -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_input_format_support(): # Describes all encoders - from .._externals import supported_videoreader_formats + from ._externals import supported_videoreader_formats supported = supported_videoreader_formats() @@ -46,11 +46,11 @@ def test_input_format_support(): for fmt in ('avi', 'mov', 'mp4'): assert fmt in supported -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_output_format_support(): # Describes all encoders - from .._externals import supported_videowriter_formats + from ._externals import supported_videowriter_formats supported = supported_videowriter_formats() @@ -58,10 +58,10 @@ def test_output_format_support(): for fmt in ('avi', 'mov', 'mp4'): assert fmt in supported -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_video_reader_attributes(): - from .. import VideoReader + from . import VideoReader iv = VideoReader(INPUT_VIDEO) @@ -88,19 +88,19 @@ def test_video_reader_attributes(): nose.tools.eq_(len(iv.video_type[2]), len(iv.frame_type[2])+1) assert isinstance(iv.info, str) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_video_reader_str(): - from .. import VideoReader + from . import VideoReader iv = VideoReader(INPUT_VIDEO) assert repr(iv) assert str(iv) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_can_iterate(): - from .. import VideoReader + from . import VideoReader video = VideoReader(INPUT_VIDEO) counter = 0 for frame in video: @@ -113,10 +113,10 @@ def test_can_iterate(): assert counter == len(video) #we have gone through all frames -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_iteration(): - - from .. import load, VideoReader + + from . import load, VideoReader f = VideoReader(INPUT_VIDEO) objs = load(INPUT_VIDEO) @@ -124,10 +124,10 @@ def test_iteration(): for l, i in zip(objs, f): assert numpy.allclose(l, i) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_indexing(): - from .. import VideoReader + from . import VideoReader f = VideoReader(INPUT_VIDEO) nose.tools.eq_(len(f), 375) @@ -143,30 +143,30 @@ def test_indexing(): assert numpy.allclose(f[len(f)-1], f[-1]) assert numpy.allclose(f[len(f)-2], f[-2]) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_slicing_empty(): - from .. import load, VideoReader + from . import load, VideoReader f = VideoReader(INPUT_VIDEO) objs = f[1:1] assert objs.shape == tuple() assert objs.dtype == numpy.uint8 -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_slicing_0(): - from .. import load, VideoReader + from . import load, VideoReader f = VideoReader(INPUT_VIDEO) objs = f[:] for i, k in enumerate(load(INPUT_VIDEO)): assert numpy.allclose(k, objs[i]) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_slicing_1(): - from .. import VideoReader + from . import VideoReader f = VideoReader(INPUT_VIDEO) s = f[3:10:2] @@ -176,10 +176,10 @@ def test_slicing_1(): assert numpy.allclose(s[2], f[7]) assert numpy.allclose(s[3], f[9]) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_slicing_2(): - from .. import VideoReader + from . import VideoReader f = VideoReader(INPUT_VIDEO) s = f[-10:-2:3] @@ -188,10 +188,10 @@ def test_slicing_2(): assert numpy.allclose(s[1], f[len(f)-7]) assert numpy.allclose(s[2], f[len(f)-4]) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_slicing_3(): - from .. import VideoReader + from . import VideoReader f = VideoReader(INPUT_VIDEO) objs = f.load() @@ -203,10 +203,10 @@ def test_slicing_3(): assert numpy.allclose(s[2], f[14]) assert numpy.allclose(s[3], f[11]) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_slicing_4(): - from .. import VideoReader + from . import VideoReader f = VideoReader(INPUT_VIDEO) objs = f[:21] @@ -219,10 +219,10 @@ def test_slicing_4(): assert numpy.allclose(s[3], f[len(f)-19]) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def test_can_use_array_interface(): - from .. import load, VideoReader + from . import load, VideoReader array = load(INPUT_VIDEO) iv = VideoReader(INPUT_VIDEO) diff --git a/xbob/io/test/test_video_codec.py b/xbob/io/test_video_codec.py similarity index 91% rename from xbob/io/test/test_video_codec.py rename to xbob/io/test_video_codec.py index 226f5a4..542abd5 100644 --- a/xbob/io/test/test_video_codec.py +++ b/xbob/io/test_video_codec.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # vim: set fileencoding=utf-8 : # Andre Anjos <andre.anjos@idiap.ch> -# Tue 12 Nov 09:25:56 2013 +# Tue 12 Nov 09:25:56 2013 """Runs quality tests on video codecs supported """ @@ -9,17 +9,17 @@ import os import numpy import nose.tools -from . import utils as testutils -from ..utils import color_distortion, frameskip_detection, quality_degradation +from . import test_utils +from .utils import color_distortion, frameskip_detection, quality_degradation # These are some global parameters for the test. -INPUT_VIDEO = testutils.datafile('test.mov', __name__) +INPUT_VIDEO = test_utils.datafile('test.mov', __name__) -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def check_format_codec(function, shape, framerate, format, codec, maxdist): length, height, width = shape - fname = testutils.temporary_filename(suffix='.%s' % format) + fname = test_utils.temporary_filename(suffix='.%s' % format) try: orig, framerate, encoded = function(shape, framerate, format, codec, fname) @@ -90,7 +90,7 @@ def test_format_codecs(): ) # some exceptions - if testutils.ffmpeg_version_lessthan('0.6'): + if test_utils.ffmpeg_version_lessthan('0.6'): distortions['ffv1']['frameskip'] = 0.55 distortions['mpeg1video']['frameskip'] = 1.5 distortions['mpegvideo']['color'] = 9.0 @@ -98,9 +98,9 @@ def test_format_codecs(): distortions['mpeg2video']['color'] = 9.0 distortions['mpeg2video']['frameskip'] = 1.4 - from .._externals import versions + from ._externals import versions if versions['FFmpeg']['ffmpeg'] != 'unavailable': - from .._externals import supported_videowriter_formats + from ._externals import supported_videowriter_formats SUPPORTED = supported_videowriter_formats() for format in SUPPORTED: for codec in SUPPORTED[format]['supported_codecs']: @@ -109,11 +109,11 @@ def test_format_codecs(): distortion = distortions.get(codec, distortions['default'])[method] yield check_format_codec, methods[method], shape, framerate, format, codec, distortion -@testutils.ffmpeg_found() +@test_utils.ffmpeg_found() def check_user_video(format, codec, maxdist): - from .. import VideoReader, VideoWriter - fname = testutils.temporary_filename(suffix='.%s' % format) + from . import VideoReader, VideoWriter + fname = test_utils.temporary_filename(suffix='.%s' % format) MAXLENTH = 10 #use only the first 10 frames try: @@ -181,9 +181,9 @@ def test_user_video(): msmpeg4v2 = 2.3, ) - from .._externals import versions + from ._externals import versions if versions['FFmpeg']['ffmpeg'] != 'unavailable': - from .._externals import supported_videowriter_formats + from ._externals import supported_videowriter_formats SUPPORTED = supported_videowriter_formats() for format in SUPPORTED: for codec in SUPPORTED[format]['supported_codecs']: -- GitLab