diff options
| author | nik-bes <[email protected]> | 2025-05-19 07:20:13 +0300 |
|---|---|---|
| committer | nik-bes <[email protected]> | 2025-05-19 07:36:02 +0300 |
| commit | 317b7368e24941ff76499f500579fd9b10f6656e (patch) | |
| tree | abbcbaea595e7d2e9f23cf59a408b3082fe4340d /contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py | |
| parent | 6b666a52d40308ab9b3532cd8d3008b9f37cfffb (diff) | |
Update Cython to 3.0.10.
commit_hash:b43c96b868cd36d636192fd2c6024d9f0d2fb6f8
Diffstat (limited to 'contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py')
| -rw-r--r-- | contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py b/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py index bd7608d6079..bb06c2905b9 100644 --- a/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py +++ b/contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py @@ -134,7 +134,7 @@ class TestDebugInformationClasses(DebugTestCase): self.assertEqual(self.spam_func.arguments, ['a']) self.assertEqual(self.spam_func.step_into_functions, - set(['puts', 'some_c_function'])) + {'puts', 'some_c_function'}) expected_lineno = test_libcython.source_to_lineno['def spam(a=0):'] self.assertEqual(self.spam_func.lineno, expected_lineno) @@ -177,12 +177,13 @@ class TestBreak(DebugTestCase): assert step_result.rstrip().endswith(nextline) -class TestKilled(DebugTestCase): - - def test_abort(self): - gdb.execute("set args -c 'import os; os.abort()'") - output = gdb.execute('cy run', to_string=True) - assert 'abort' in output.lower() +# I removed this testcase, because it will never work, because +# gdb.execute(..., to_string=True) does not capture stdout and stderr of python. +# class TestKilled(DebugTestCase): +# def test_abort(self): +# gdb.execute("set args -c 'import os;print(123456789);os.abort()'") +# output = gdb.execute('cy run', to_string=True) +# assert 'abort' in output.lower() class DebugStepperTestCase(DebugTestCase): @@ -322,6 +323,61 @@ class TestPrint(DebugTestCase): self.break_and_run('c = 2') result = gdb.execute('cy print b', to_string=True) self.assertEqual('b = (int) 1\n', result) + result = gdb.execute('cy print python_var', to_string=True) + self.assertEqual('python_var = 13\n', result) + result = gdb.execute('cy print c_var', to_string=True) + self.assertEqual('c_var = (int) 12\n', result) + +correct_result_test_list_inside_func = '''\ + 14 int b, c + 15 + 16 b = c = d = 0 + 17 + 18 b = 1 +> 19 c = 2 + 20 int(10) + 21 puts("spam") + 22 os.path.join("foo", "bar") + 23 some_c_function() +''' +correct_result_test_list_outside_func = '''\ + 5 void some_c_function() + 6 + 7 import os + 8 + 9 cdef int c_var = 12 +> 10 python_var = 13 + 11 + 12 def spam(a=0): + 13 cdef: + 14 int b, c +''' + + +class TestList(DebugTestCase): + def workaround_for_coding_style_checker(self, correct_result_wrong_whitespace): + correct_result = "" + for line in correct_result_test_list_inside_func.split("\n"): + if len(line) < 10 and len(line) > 0: + line += " "*4 + correct_result += line + "\n" + correct_result = correct_result[:-1] + + def test_list_inside_func(self): + self.break_and_run('c = 2') + result = gdb.execute('cy list', to_string=True) + # We don't want to fail because of some trailing whitespace, + # so we remove trailing whitespaces with the following line + result = "\n".join([line.rstrip() for line in result.split("\n")]) + self.assertEqual(correct_result_test_list_inside_func, result) + + def test_list_outside_func(self): + self.break_and_run('python_var = 13') + result = gdb.execute('cy list', to_string=True) + # We don't want to fail because of some trailing whitespace, + # so we remove trailing whitespaces with the following line + result = "\n".join([line.rstrip() for line in result.split("\n")]) + self.assertEqual(correct_result_test_list_outside_func, result) class TestUpDown(DebugTestCase): @@ -362,6 +418,7 @@ class TestExec(DebugTestCase): # test normal behaviour self.assertEqual("[0]", self.eval_command('[a]')) + return #The test after this return freezes gdb, so I temporarily removed it. # test multiline code result = gdb.execute(textwrap.dedent('''\ cy exec |
