From 45fae976f0972db51cbddd4b0babfeb4530a8fa3 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Fri, 23 Sep 2022 16:30:43 -0700 Subject: [PATCH] test optimizations --- tests/templates/_test_foo.py | 9 ++++----- tests/templates/_test_foo_s.py | 9 ++++----- tests/test_proc_buddyinfo.py | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/templates/_test_foo.py b/tests/templates/_test_foo.py index fcdd1c30..e9440b6f 100644 --- a/tests/templates/_test_foo.py +++ b/tests/templates/_test_foo.py @@ -20,11 +20,10 @@ class MyTests(unittest.TestCase): } for file, filepaths in fixtures.items(): - with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as f: - cls.f_in[file] = f.read() - - with open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as f: - cls.f_json[file] = json.loads(f.read()) + with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \ + open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b: + cls.f_in[file] = a.read() + cls.f_json[file] = json.loads(b.read()) def test_foo_nodata(self): diff --git a/tests/templates/_test_foo_s.py b/tests/templates/_test_foo_s.py index 1596c4ea..675567a6 100644 --- a/tests/templates/_test_foo_s.py +++ b/tests/templates/_test_foo_s.py @@ -23,11 +23,10 @@ class MyTests(unittest.TestCase): } for file, filepaths in fixtures.items(): - with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as f: - cls.f_in[file] = f.read() - - with open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as f: - cls.f_json[file] = json.loads(f.read()) + with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \ + open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b: + cls.f_in[file] = a.read() + cls.f_json[file] = json.loads(b.read()) def test_foo_s_nodata(self): diff --git a/tests/test_proc_buddyinfo.py b/tests/test_proc_buddyinfo.py index 6418a0bd..6d74572b 100644 --- a/tests/test_proc_buddyinfo.py +++ b/tests/test_proc_buddyinfo.py @@ -20,11 +20,10 @@ class MyTests(unittest.TestCase): } for file, filepaths in fixtures.items(): - with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as f: - cls.f_in[file] = f.read() - - with open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as f: - cls.f_json[file] = json.loads(f.read()) + with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \ + open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b: + cls.f_in[file] = a.read() + cls.f_json[file] = json.loads(b.read()) def test_proc_buddyinfo_nodata(self):