test_base_api: generate uncompressed files as well
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 17 Dec 2012 13:22:21 +0000 (15:22 +0200)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Mon, 17 Dec 2012 14:50:27 +0000 (16:50 +0200)
Improve the '_generate_compressed_files()' and make it generate uncompressed
vesion of the file as well.

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

index 22ff908..14f6fc9 100644 (file)
@@ -58,6 +58,16 @@ def _generate_compressed_files(file_obj, delete = True):
     # Put the temporary files in the directory with 'file_obj'
     directory = os.path.dirname(file_obj.name)
 
+    # Generate an uncompressed version of the file
+    tmp_file_obj = tempfile.NamedTemporaryFile('wb+', prefix = prefix,
+                                               delete = delete, dir = directory,
+                                               suffix = '.uncompressed')
+    file_obj.seek(0)
+    shutil.copyfileobj(file_obj, tmp_file_obj)
+    tmp_file_obj.flush()
+    yield tmp_file_obj.name
+    tmp_file_obj.close()
+
     # Generate a .bz2 version of the file
     tmp_file_obj = tempfile.NamedTemporaryFile('wb+', prefix = prefix,
                                                delete = delete, dir = directory,