summaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Debugger/Tests
diff options
context:
space:
mode:
authornik-bes <[email protected]>2025-05-19 07:20:13 +0300
committernik-bes <[email protected]>2025-05-19 07:36:02 +0300
commit317b7368e24941ff76499f500579fd9b10f6656e (patch)
treeabbcbaea595e7d2e9f23cf59a408b3082fe4340d /contrib/tools/cython/Cython/Debugger/Tests
parent6b666a52d40308ab9b3532cd8d3008b9f37cfffb (diff)
Update Cython to 3.0.10.
commit_hash:b43c96b868cd36d636192fd2c6024d9f0d2fb6f8
Diffstat (limited to 'contrib/tools/cython/Cython/Debugger/Tests')
-rw-r--r--contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py10
-rw-r--r--contrib/tools/cython/Cython/Debugger/Tests/codefile5
-rw-r--r--contrib/tools/cython/Cython/Debugger/Tests/test_libcython_in_gdb.py71
-rw-r--r--contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py5
4 files changed, 73 insertions, 18 deletions
diff --git a/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py b/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py
index 13560646ffc..0d8a3e6138a 100644
--- a/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py
+++ b/contrib/tools/cython/Cython/Debugger/Tests/TestLibCython.py
@@ -56,13 +56,13 @@ def test_gdb():
stdout, _ = p.communicate()
try:
internal_python_version = list(map(int, stdout.decode('ascii', 'ignore').split()))
- if internal_python_version < [2, 6]:
+ if internal_python_version < [2, 7]:
have_gdb = False
except ValueError:
have_gdb = False
if not have_gdb:
- warnings.warn('Skipping gdb tests, need gdb >= 7.2 with Python >= 2.6')
+ warnings.warn('Skipping gdb tests, need gdb >= 7.2 with Python >= 2.7')
return have_gdb
@@ -99,6 +99,7 @@ class DebuggerTestCase(unittest.TestCase):
opts = dict(
test_directory=self.tempdir,
module='codefile',
+ module_path=self.destfile,
)
optimization_disabler = build_ext.Optimization()
@@ -131,10 +132,11 @@ class DebuggerTestCase(unittest.TestCase):
)
cython_compile_testcase.run_distutils(
+ test_directory=opts['test_directory'],
+ module=opts['module'],
+ workdir=opts['test_directory'],
incdir=None,
- workdir=self.tempdir,
extra_extension_args={'extra_objects':['cfuncs.o']},
- **opts
)
finally:
optimization_disabler.restore_state()
diff --git a/contrib/tools/cython/Cython/Debugger/Tests/codefile b/contrib/tools/cython/Cython/Debugger/Tests/codefile
index 6b4c6b6addf..ee587cbb130 100644
--- a/contrib/tools/cython/Cython/Debugger/Tests/codefile
+++ b/contrib/tools/cython/Cython/Debugger/Tests/codefile
@@ -37,14 +37,13 @@ def outer():
def inner():
b = 2
# access closed over variables
- print a, b
+ print(a, b)
return inner
-
outer()()
spam()
-print "bye!"
+print("bye!")
def use_ham():
ham()
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
diff --git a/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py b/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py
index 6f34cee47b3..4640dbac10b 100644
--- a/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py
+++ b/contrib/tools/cython/Cython/Debugger/Tests/test_libpython_in_gdb.py
@@ -6,16 +6,13 @@ Lib/test/test_gdb.py in the Python source. These tests are run in gdb and
called from test_libcython_in_gdb.main()
"""
-import os
-import sys
-
import gdb
from Cython.Debugger import libcython
from Cython.Debugger import libpython
from . import test_libcython_in_gdb
-from .test_libcython_in_gdb import _debug, inferior_python_version
+from .test_libcython_in_gdb import inferior_python_version
class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):