From d48272b269d529d1b83eda9c28e03ac6597747a5 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 23 Jul 2024 17:12:36 +0200 Subject: [PATCH] test/cli/proj2_test.py: made some symbols private --- test/cli/proj2_test.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/cli/proj2_test.py b/test/cli/proj2_test.py index a9493657841..2fdecbb07b3 100644 --- a/test/cli/proj2_test.py +++ b/test/cli/proj2_test.py @@ -8,19 +8,19 @@ __script_dir = os.path.dirname(os.path.abspath(__file__)) __proj_dir = os.path.join(__script_dir, 'proj2') -COMPILE_COMMANDS_JSON = 'compile_commands.json' +__COMPILE_COMMANDS_JSON = 'compile_commands.json' -ERR_A = ('%s:1:7: error: Division by zero. [zerodiv]\n' + - 'x = 3 / 0;\n' + - ' ^\n') % os.path.join('a', 'a.c') -ERR_B = ('%s:1:7: error: Division by zero. [zerodiv]\n' + - 'x = 3 / 0;\n' + - ' ^\n') % os.path.join('b', 'b.c') +__ERR_A = ('%s:1:7: error: Division by zero. [zerodiv]\n' + + 'x = 3 / 0;\n' + + ' ^\n') % os.path.join('a', 'a.c') +__ERR_B = ('%s:1:7: error: Division by zero. [zerodiv]\n' + + 'x = 3 / 0;\n' + + ' ^\n') % os.path.join('b', 'b.c') -def create_compile_commands(): +def __create_compile_commands(): j = [{'directory': os.path.join(__proj_dir, 'a'), 'command': 'gcc -c a.c', 'file': 'a.c'}, {'directory': __proj_dir, 'command': 'gcc -c b/b.c', 'file': 'b/b.c'}] - with open(os.path.join(__proj_dir, COMPILE_COMMANDS_JSON), 'wt') as f: + with open(os.path.join(__proj_dir, __COMPILE_COMMANDS_JSON), 'wt') as f: f.write(json.dumps(j)) @@ -35,7 +35,7 @@ def test_file_filter(): assert stdout.find('Checking %s ...' % file2) >= 0 def test_local_path(): - create_compile_commands() + __create_compile_commands() ret, stdout, _ = cppcheck(['--project=compile_commands.json'], cwd=__proj_dir) file1 = os.path.join('a', 'a.c') file2 = os.path.join('b', 'b.c') @@ -44,20 +44,20 @@ def test_local_path(): assert stdout.find('Checking %s ...' % file2) >= 0 def test_local_path_force(): - create_compile_commands() + __create_compile_commands() ret, stdout, _ = cppcheck(['--project=compile_commands.json', '--force'], cwd=__proj_dir) assert ret == 0, stdout assert stdout.find('AAA') >= 0 def test_local_path_maxconfigs(): - create_compile_commands() + __create_compile_commands() ret, stdout, _ = cppcheck(['--project=compile_commands.json', '--max-configs=2'], cwd=__proj_dir) assert ret == 0, stdout assert stdout.find('AAA') >= 0 def test_relative_path(): - create_compile_commands() - ret, stdout, _ = cppcheck(['--project=proj2/' + COMPILE_COMMANDS_JSON], cwd=__script_dir) + __create_compile_commands() + ret, stdout, _ = cppcheck(['--project=proj2/' + __COMPILE_COMMANDS_JSON], cwd=__script_dir) file1 = os.path.join('proj2', 'a', 'a.c') file2 = os.path.join('proj2', 'b', 'b.c') assert ret == 0, stdout @@ -65,8 +65,8 @@ def test_relative_path(): assert stdout.find('Checking %s ...' % file2) >= 0 def test_absolute_path(): - create_compile_commands() - ret, stdout, _ = cppcheck(['--project=' + os.path.join(__proj_dir, COMPILE_COMMANDS_JSON)], cwd=__script_dir) + __create_compile_commands() + ret, stdout, _ = cppcheck(['--project=' + os.path.join(__proj_dir, __COMPILE_COMMANDS_JSON)], cwd=__script_dir) file1 = os.path.join(__proj_dir, 'a', 'a.c') file2 = os.path.join(__proj_dir, 'b', 'b.c') assert ret == 0, stdout @@ -74,7 +74,7 @@ def test_absolute_path(): assert stdout.find('Checking %s ...' % file2) >= 0 def test_gui_project_loads_compile_commands_1(): - create_compile_commands() + __create_compile_commands() ret, stdout, _ = cppcheck(['--project=proj2/proj2.cppcheck'], cwd=__script_dir) file1 = os.path.join('proj2', 'a', 'a.c') file2 = os.path.join('proj2', 'b', 'b.c') @@ -83,7 +83,7 @@ def test_gui_project_loads_compile_commands_1(): assert stdout.find('Checking %s ...' % file2) >= 0 def test_gui_project_loads_compile_commands_2(): - create_compile_commands() + __create_compile_commands() exclude_path_1 = 'proj2/b' create_gui_project_file(os.path.join(__proj_dir, 'test.cppcheck'), import_project='compile_commands.json', @@ -130,13 +130,13 @@ def test_gui_project_loads_relative_vs_solution_2(): create_gui_project_file(os.path.join(__script_dir, 'test.cppcheck'), root_path='proj2', import_project='proj2/proj2.sln') ret, stdout, stderr = cppcheck(['--project=test.cppcheck'], cwd=__script_dir) assert ret == 0, stdout - assert stderr == ERR_A + ERR_B + assert stderr == __ERR_A + __ERR_B def test_gui_project_loads_relative_vs_solution_with_exclude(): create_gui_project_file(os.path.join(__script_dir, 'test.cppcheck'), root_path='proj2', import_project='proj2/proj2.sln', exclude_paths=['b']) ret, stdout, stderr = cppcheck(['--project=test.cppcheck'], cwd=__script_dir) assert ret == 0, stdout - assert stderr == ERR_A + assert stderr == __ERR_A def test_gui_project_loads_absolute_vs_solution_2(): create_gui_project_file(os.path.join(__script_dir, 'test.cppcheck'), @@ -144,4 +144,4 @@ def test_gui_project_loads_absolute_vs_solution_2(): import_project=os.path.join(__proj_dir, 'proj2.sln')) ret, stdout, stderr = cppcheck(['--project=test.cppcheck'], cwd=__script_dir) assert ret == 0, stdout - assert stderr == ERR_A + ERR_B + assert stderr == __ERR_A + __ERR_B