From 9dc1da1e5bf4d585900e65614eca3c8d506c45c6 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 24 Jan 2024 10:36:52 +0200 Subject: [PATCH 1/3] boilerplate_test: fix bad indentation --- hack/boilerplate/boilerplate_test.py | 42 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/hack/boilerplate/boilerplate_test.py b/hack/boilerplate/boilerplate_test.py index 389e812a599..09ea600505d 100644 --- a/hack/boilerplate/boilerplate_test.py +++ b/hack/boilerplate/boilerplate_test.py @@ -20,33 +20,33 @@ from io import StringIO import os import sys + class TestBoilerplate(unittest.TestCase): - """ - Note: run this test from the hack/boilerplate directory. + """ + Note: run this test from the hack/boilerplate directory. - $ python -m unittest boilerplate_test - """ + $ python -m unittest boilerplate_test + """ - def test_boilerplate(self): - os.chdir("test/") + def test_boilerplate(self): + os.chdir("test/") - class Args(object): - def __init__(self): - self.filenames = [] - self.rootdir = "." - self.boilerplate_dir = "../" - self.verbose = True + class Args(object): + def __init__(self): + self.filenames = [] + self.rootdir = "." + self.boilerplate_dir = "../" + self.verbose = True - # capture stdout - old_stdout = sys.stdout - sys.stdout = StringIO.StringIO() + # capture stdout + old_stdout = sys.stdout + sys.stdout = StringIO.StringIO() - boilerplate.args = Args() - ret = boilerplate.main() + boilerplate.args = Args() + ret = boilerplate.main() - output = sorted(sys.stdout.getvalue().split()) + output = sorted(sys.stdout.getvalue().split()) - sys.stdout = old_stdout + sys.stdout = old_stdout - self.assertEqual( - output, ['././fail.go', '././fail.py']) + self.assertEqual(output, ["././fail.go", "././fail.py"]) From 4473dfebbf945e7b05e4de6367109c352cfa6b67 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 24 Jan 2024 10:42:16 +0200 Subject: [PATCH 2/3] fix boilerplate test Fixed AttributeError: type object '_io.StringIO' has no attribute 'StringIO' --- hack/boilerplate/boilerplate_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/boilerplate/boilerplate_test.py b/hack/boilerplate/boilerplate_test.py index 09ea600505d..d95194b2211 100644 --- a/hack/boilerplate/boilerplate_test.py +++ b/hack/boilerplate/boilerplate_test.py @@ -40,7 +40,7 @@ class TestBoilerplate(unittest.TestCase): # capture stdout old_stdout = sys.stdout - sys.stdout = StringIO.StringIO() + sys.stdout = StringIO() boilerplate.args = Args() ret = boilerplate.main() From 83de1586e08f86bf8d6f99169ca648277fbf30e1 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 24 Jan 2024 10:56:36 +0200 Subject: [PATCH 3/3] boilerplate_test:fix pylint warnings Fixed the following Pylint warnings: boilerplate_test.py:34:8: R0205: Class 'Args' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) boilerplate_test.py:46:8: W0612: Unused variable 'ret' (unused-variable) boilerplate_test.py:18:0: C0411: standard import "import unittest" should be placed before "import boilerplate" (wrong-import-order) boilerplate_test.py:19:0: C0411: standard import "from io import StringIO" should be placed before "import boilerplate" (wrong-import-order) boilerplate_test.py:20:0: C0411: standard import "import os" should be placed before "import boilerplate" (wrong-import-order) boilerplate_test.py:21:0: C0411: standard import "import sys" should be placed before "import boilerplate" (wrong-import-order) --- hack/boilerplate/boilerplate_test.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hack/boilerplate/boilerplate_test.py b/hack/boilerplate/boilerplate_test.py index d95194b2211..8fc7e4cbcb1 100644 --- a/hack/boilerplate/boilerplate_test.py +++ b/hack/boilerplate/boilerplate_test.py @@ -14,12 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import boilerplate -import unittest -from io import StringIO import os import sys +import unittest +from io import StringIO + +import boilerplate class TestBoilerplate(unittest.TestCase): """ @@ -31,19 +32,19 @@ class TestBoilerplate(unittest.TestCase): def test_boilerplate(self): os.chdir("test/") - class Args(object): - def __init__(self): - self.filenames = [] - self.rootdir = "." - self.boilerplate_dir = "../" - self.verbose = True + class Args: + filenames = [] + rootdir = "." + boilerplate_dir = "../" + verbose = True # capture stdout old_stdout = sys.stdout sys.stdout = StringIO() - boilerplate.args = Args() + boilerplate.args = Args ret = boilerplate.main() + self.assertEqual(ret, 0) output = sorted(sys.stdout.getvalue().split())