[Patchew-devel] [PATCH] Use gzip module

Shubham Jain posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180329055505.27452-1-shubhamjain7495@gmail.com
tests/patchewtest.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[Patchew-devel] [PATCH] Use gzip module
Posted by Shubham Jain 6 years ago
In class PatchewTestCase, cat doesn't stat the ".gz" files for MacOS. Changed it to use the gzip module instead of subprocess.
---
 tests/patchewtest.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/patchewtest.py b/tests/patchewtest.py
index 7e51e70..5bed3b9 100644
--- a/tests/patchewtest.py
+++ b/tests/patchewtest.py
@@ -16,6 +16,7 @@ import shutil
 import argparse
 import json
 import atexit
+import gzip
 
 BASE_DIR = os.path.join(os.path.dirname(__file__), "..")
 
@@ -102,7 +103,9 @@ class PatchewTestCase(django.test.LiveServerTestCase):
     def get_data_path(self, fname):
         r = tempfile.NamedTemporaryFile(dir=RUN_DIR, prefix="test-data-", delete=False)
         d = os.path.join(BASE_DIR, "tests", "data", fname)
-        r.write(subprocess.check_output(["zcat", d]))
+        with gzip.open(d, 'rb') as f:
+            file_content = f.read()
+        r.write(file_content)
         r.close()
         return r.name
 
-- 
2.14.3 (Apple Git-98)

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
Re: [Patchew-devel] [PATCH] Use gzip module
Posted by Fam Zheng 6 years ago
On Thu, 03/29 11:25, Shubham Jain wrote:
> In class PatchewTestCase, cat doesn't stat the ".gz" files for MacOS. Changed it to use the gzip module instead of subprocess.
> ---
>  tests/patchewtest.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/patchewtest.py b/tests/patchewtest.py
> index 7e51e70..5bed3b9 100644
> --- a/tests/patchewtest.py
> +++ b/tests/patchewtest.py
> @@ -16,6 +16,7 @@ import shutil
>  import argparse
>  import json
>  import atexit
> +import gzip
>  
>  BASE_DIR = os.path.join(os.path.dirname(__file__), "..")
>  
> @@ -102,7 +103,9 @@ class PatchewTestCase(django.test.LiveServerTestCase):
>      def get_data_path(self, fname):
>          r = tempfile.NamedTemporaryFile(dir=RUN_DIR, prefix="test-data-", delete=False)
>          d = os.path.join(BASE_DIR, "tests", "data", fname)
> -        r.write(subprocess.check_output(["zcat", d]))
> +        with gzip.open(d, 'rb') as f:
> +            file_content = f.read()
> +        r.write(file_content)
>          r.close()
>          return r.name
>  

Applied, thanks!

Fam

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel