test_fiemap: fix pylint warning
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Fri, 22 Feb 2013 09:22:34 +0000 (11:22 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 25 Feb 2013 08:20:08 +0000 (10:20 +0200)
Using builtins like 'filter()' is discouraged nowadays, and pylint generates
this warning:

W: 46,22:_check_ranges: Used builtin function 'filter'

Use a generator expression instead of the 'filter' built-in.

Change-Id: I0b07685967927a84804d443f22369d68da106af3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
tests/test_fiemap.py

index 4429ab066e58a6ba8fc00bf60d7b44ced75b50ff..f4c6f5b94e3051e82aa280864c1be3272ddd8cab 100644 (file)
@@ -42,9 +42,8 @@ def _check_ranges(f_image, fiemap, first_block, blocks_cnt,
     # starting from block 'first_block'. Create an iterator which filters
     # those block ranges from the 'ranges' list, that are out of the
     # 'first_block'/'blocks_cnt' file region.
-    filter_func = lambda x: x[1] >= first_block and x[0] <= last_block
-    ranges_iterator = filter(filter_func, ranges)
-
+    ranges_iterator = ( x for x in ranges if x[1] >= first_block and \
+                                             x[0] <= last_block )
     iterator = itertools.izip_longest(ranges_iterator, fiemap_iterator)
 
     # Iterate over both - the (filtered) 'ranges' list which contains correct