From 27a8f244bdf4194139488ff3746f89ef38980cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 5 Oct 2024 13:24:07 +0200 Subject: [PATCH] made some symbols in Python files private (#6851) --- test/cli/helloworld_test.py | 14 +++++++------- test/cli/other_test.py | 24 ++++++++++++------------ test/cli/premium_test.py | 8 ++++---- test/cli/project_test.py | 24 ++++++++++++------------ 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/test/cli/helloworld_test.py b/test/cli/helloworld_test.py index fafb9d562d5..9a5056f17dc 100644 --- a/test/cli/helloworld_test.py +++ b/test/cli/helloworld_test.py @@ -13,7 +13,7 @@ # Get Visual Studio configurations checking a file # Checking {file} {config}... -def getVsConfigs(stdout, filename): +def __getVsConfigs(stdout, filename): ret = [] for line in stdout.split('\n'): if not line.startswith('Checking %s ' % filename): @@ -148,7 +148,7 @@ def test_vs_project_local_path(): ] ret, stdout, stderr = cppcheck(args, cwd=__proj_dir) assert ret == 0, stdout - assert getVsConfigs(stdout, 'main.c') == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64' + assert __getVsConfigs(stdout, 'main.c') == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64' assert stderr == '[main.c:5]: (error) Division by zero.\n' def test_vs_project_relative_path(): @@ -159,7 +159,7 @@ def test_vs_project_relative_path(): ret, stdout, stderr = cppcheck(args, cwd=__script_dir) filename = os.path.join(__proj_dir, 'main.c') assert ret == 0, stdout - assert getVsConfigs(stdout, filename) == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64' + assert __getVsConfigs(stdout, filename) == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64' assert stderr == '[%s:5]: (error) Division by zero.\n' % filename def test_vs_project_absolute_path(): @@ -170,7 +170,7 @@ def test_vs_project_absolute_path(): ret, stdout, stderr = cppcheck(args) filename = os.path.join(__proj_dir, 'main.c') assert ret == 0, stdout - assert getVsConfigs(stdout, filename) == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64' + assert __getVsConfigs(stdout, filename) == 'Debug|Win32 Debug|x64 Release|Win32 Release|x64' assert stderr == '[%s:5]: (error) Division by zero.\n' % filename def test_cppcheck_project_local_path(): @@ -181,7 +181,7 @@ def test_cppcheck_project_local_path(): ] ret, stdout, stderr = cppcheck(args, cwd=__proj_dir) assert ret == 0, stdout - assert getVsConfigs(stdout, 'main.c') == 'Debug|x64' + assert __getVsConfigs(stdout, 'main.c') == 'Debug|x64' assert stderr == '[main.c:5]: (error) Division by zero.\n' def test_cppcheck_project_relative_path(): @@ -193,7 +193,7 @@ def test_cppcheck_project_relative_path(): ret, stdout, stderr = cppcheck(args, cwd=__script_dir) filename = os.path.join('helloworld', 'main.c') assert ret == 0, stdout - assert getVsConfigs(stdout, filename) == 'Debug|x64' + assert __getVsConfigs(stdout, filename) == 'Debug|x64' assert stderr == '[%s:5]: (error) Division by zero.\n' % filename def test_cppcheck_project_absolute_path(): @@ -205,7 +205,7 @@ def test_cppcheck_project_absolute_path(): ret, stdout, stderr = cppcheck(args) filename = os.path.join(__proj_dir, 'main.c') assert ret == 0, stdout - assert getVsConfigs(stdout, filename) == 'Debug|x64' + assert __getVsConfigs(stdout, filename) == 'Debug|x64' assert stderr == '[%s:5]: (error) Division by zero.\n' % filename def test_suppress_command_line_related(): diff --git a/test/cli/other_test.py b/test/cli/other_test.py index fb08a517575..49cf2448110 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -86,10 +86,10 @@ def test_preprocessor_error(tmpdir): assert exitcode != 0 -ANSI_BOLD = "\x1b[1m" -ANSI_FG_RED = "\x1b[31m" -ANSI_FG_DEFAULT = "\x1b[39m" -ANSI_FG_RESET = "\x1b[0m" +__ANSI_BOLD = "\x1b[1m" +__ANSI_FG_RED = "\x1b[31m" +__ANSI_FG_DEFAULT = "\x1b[39m" +__ANSI_FG_RESET = "\x1b[0m" @pytest.mark.parametrize("env,color_expected", [({"CLICOLOR_FORCE":"1"}, True), ({"NO_COLOR": "1", "CLICOLOR_FORCE":"1"}, False)]) @@ -101,10 +101,10 @@ def test_color_non_tty(tmpdir, env, color_expected): assert exitcode == 0 assert stderr - assert (ANSI_BOLD in stderr) == color_expected - assert (ANSI_FG_RED in stderr) == color_expected - assert (ANSI_FG_DEFAULT in stderr) == color_expected - assert (ANSI_FG_RESET in stderr) == color_expected + assert (__ANSI_BOLD in stderr) == color_expected + assert (__ANSI_FG_RED in stderr) == color_expected + assert (__ANSI_FG_DEFAULT in stderr) == color_expected + assert (__ANSI_FG_RESET in stderr) == color_expected @pytest.mark.skipif(sys.platform == "win32", reason="TTY not supported in Windows") @@ -117,10 +117,10 @@ def test_color_tty(tmpdir, env, color_expected): assert exitcode == 0 assert stderr - assert (ANSI_BOLD in stderr) == color_expected - assert (ANSI_FG_RED in stderr) == color_expected - assert (ANSI_FG_DEFAULT in stderr) == color_expected - assert (ANSI_FG_RESET in stderr) == color_expected + assert (__ANSI_BOLD in stderr) == color_expected + assert (__ANSI_FG_RED in stderr) == color_expected + assert (__ANSI_FG_DEFAULT in stderr) == color_expected + assert (__ANSI_FG_RESET in stderr) == color_expected def test_invalid_library(tmpdir): diff --git a/test/cli/premium_test.py b/test/cli/premium_test.py index 42aa886c3a3..dfc3ca19863 100644 --- a/test/cli/premium_test.py +++ b/test/cli/premium_test.py @@ -8,10 +8,10 @@ from testutils import cppcheck, __lookup_cppcheck_exe -PRODUCT_NAME = 'Cppcheck Premium ' + str(time.time()) +__PRODUCT_NAME = 'Cppcheck Premium ' + str(time.time()) -def copy_cppcheck_premium(tmpdir): +def __copy_cppcheck_premium(tmpdir): exe = shutil.copy2(__lookup_cppcheck_exe(), tmpdir) # add minimum cfg/std.cfg @@ -28,7 +28,7 @@ def copy_cppcheck_premium(tmpdir): "about": "NAME", "safety": true } - """.replace('NAME', PRODUCT_NAME)) + """.replace('NAME', __PRODUCT_NAME)) return exe @@ -42,7 +42,7 @@ def test_misra_c_builtin_style_checks(tmpdir): with open(test_file, 'wt') as f: f.write('void foo() { int x; y = 0; }') - exe = copy_cppcheck_premium(tmpdir) + exe = __copy_cppcheck_premium(tmpdir) exitcode, _, stderr = cppcheck(['--premium=autosar', '--xml', test_file], cppcheck_exe=exe) assert exitcode == 0 diff --git a/test/cli/project_test.py b/test/cli/project_test.py index 8ac243007ba..e95c1df61e8 100644 --- a/test/cli/project_test.py +++ b/test/cli/project_test.py @@ -17,7 +17,7 @@ def test_missing_project(project_ext): assert "" == stderr -def _test_project_error(tmpdir, ext, content, expected): +def __test_project_error(tmpdir, ext, content, expected): project_file = os.path.join(tmpdir, "file.{}".format(ext)) with open(project_file, 'w') as f: @@ -38,7 +38,7 @@ def _test_project_error(tmpdir, ext, content, expected): ("cppcheck", "Cppcheck GUI project file is not a valid XML - XML_ERROR_EMPTY_DOCUMENT") ]) def test_empty_project(tmpdir, project_ext, expected): - _test_project_error(tmpdir, project_ext, None, expected) + __test_project_error(tmpdir, project_ext, None, expected) def test_json_entry_file_not_found(tmpdir): @@ -53,7 +53,7 @@ def test_json_entry_file_not_found(tmpdir): if sys.platform == "win32": expected = expected.replace('\\', '/') - _test_project_error(tmpdir, "json", json.dumps(compilation_db), expected) + __test_project_error(tmpdir, "json", json.dumps(compilation_db), expected) def test_json_no_arguments(tmpdir): @@ -65,7 +65,7 @@ def test_json_no_arguments(tmpdir): expected = "no 'arguments' or 'command' field found in compilation database entry" - _test_project_error(tmpdir, "json", json.dumps(compilation_db), expected) + __test_project_error(tmpdir, "json", json.dumps(compilation_db), expected) def test_json_invalid_arguments(tmpdir): @@ -78,7 +78,7 @@ def test_json_invalid_arguments(tmpdir): expected = "'arguments' field in compilation database entry is not a JSON array" - _test_project_error(tmpdir, "json", json.dumps(compilation_db), expected) + __test_project_error(tmpdir, "json", json.dumps(compilation_db), expected) def test_sln_invalid_file(tmpdir): @@ -86,7 +86,7 @@ def test_sln_invalid_file(tmpdir): expected = "Visual Studio solution file header not found" - _test_project_error(tmpdir, "sln", content, expected) + __test_project_error(tmpdir, "sln", content, expected) def test_sln_no_header(tmpdir): @@ -95,7 +95,7 @@ def test_sln_no_header(tmpdir): expected = "Visual Studio solution file header not found" - _test_project_error(tmpdir, "sln", content, expected) + __test_project_error(tmpdir, "sln", content, expected) def test_sln_no_projects(tmpdir): @@ -104,7 +104,7 @@ def test_sln_no_projects(tmpdir): expected = "no projects found in Visual Studio solution file" - _test_project_error(tmpdir, "sln", content, expected) + __test_project_error(tmpdir, "sln", content, expected) def test_sln_project_file_not_found(tmpdir): @@ -124,7 +124,7 @@ def test_sln_project_file_not_found(tmpdir): if sys.platform == "win32": expected = expected.replace('\\', '/') - _test_project_error(tmpdir, "sln", content, expected) + __test_project_error(tmpdir, "sln", content, expected) def test_vcxproj_no_xml_root(tmpdir): @@ -132,7 +132,7 @@ def test_vcxproj_no_xml_root(tmpdir): expected = "Visual Studio project file has no XML root node" - _test_project_error(tmpdir, "vcxproj", content, expected) + __test_project_error(tmpdir, "vcxproj", content, expected) def test_bpr_no_xml_root(tmpdir): @@ -140,7 +140,7 @@ def test_bpr_no_xml_root(tmpdir): expected = "Borland project file has no XML root node" - _test_project_error(tmpdir, "bpr", content, expected) + __test_project_error(tmpdir, "bpr", content, expected) def test_cppcheck_no_xml_root(tmpdir): @@ -148,4 +148,4 @@ def test_cppcheck_no_xml_root(tmpdir): expected = "Cppcheck GUI project file has no XML root node" - _test_project_error(tmpdir, "cppcheck", content, expected) + __test_project_error(tmpdir, "cppcheck", content, expected)