From aaff8b8ac968bce9821d6fef22b1296247a9df09 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 24 Feb 2022 13:46:34 +0530 Subject: gn3: Explicitly specify UTF-8 to be the file encoding. When the encoding is not specified explicitly, the system default encoding is used. This is not recommended. * gn3/computations/ctl.py (call_ctl_script), gn3/computations/gemma.py (generate_pheno_txt_file), gn3/computations/parsers.py (parse_genofile), gn3/computations/partial_correlations.py (partial_correlations_fast), gn3/computations/rqtl.py (process_rqtl_output, process_perm_output), gn3/computations/wgcna.py (dump_wgcna_data, call_wgcna_script), gn3/fs_helpers.py (jsonfile_to_dict): Explicitly specify UTF-8 to be the file encoding. * tests/unit/computations/test_gemma.py (TestGemma.test_generate_pheno_txt_file), tests/unit/computations/test_wgcna.py (TestWgcna.test_create_json_file): Test for call to open with encoding='utf-8' argument. --- tests/unit/computations/test_gemma.py | 2 +- tests/unit/computations/test_wgcna.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/computations/test_gemma.py b/tests/unit/computations/test_gemma.py index b36a93e..137c95c 100644 --- a/tests/unit/computations/test_gemma.py +++ b/tests/unit/computations/test_gemma.py @@ -22,7 +22,7 @@ class TestGemma(unittest.TestCase): self.assertEqual(_file, ("/tmp/gn2/phenotype_" "P7y6QWnwBPedSZdL0+m/GQ.txt")) open_mock.assert_called_with(("/tmp/gn2/phenotype_" - "P7y6QWnwBPedSZdL0+m/GQ.txt"), "w") + "P7y6QWnwBPedSZdL0+m/GQ.txt"), "w", encoding="utf-8") open_mock.return_value.write.assert_has_calls([ mock.call("NA\n"), mock.call("NA\n"), diff --git a/tests/unit/computations/test_wgcna.py b/tests/unit/computations/test_wgcna.py index 3130374..a9108b0 100644 --- a/tests/unit/computations/test_wgcna.py +++ b/tests/unit/computations/test_wgcna.py @@ -166,7 +166,7 @@ class TestWgcna(TestCase): expected_input) file_handler.assert_called_once_with( - "/tmp/facb73ff-7eef-4053-b6ea-e91d3a22a00c.json", 'w') + "/tmp/facb73ff-7eef-4053-b6ea-e91d3a22a00c.json", 'w', encoding='utf-8') self.assertEqual( results, "/tmp/facb73ff-7eef-4053-b6ea-e91d3a22a00c.json") -- cgit v1.2.3