Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-140550: Update xxlimited with 3.15 limited API & PEP 697#142827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
encukou wants to merge13 commits intopython:main
base:main
Choose a base branch
Loading
fromencukou:xxlimited-3.15
Draft
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Run tests for all the xxlimited* modules
  • Loading branch information
@encukou
encukou committedDec 15, 2025
commit65f3fd08de8a3ba7e94d78c5f4de5e6f3a1e2125
101 changes: 60 additions & 41 deletionsLib/test/test_xxlimited.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,17 +3,38 @@
import types

xxlimited = import_helper.import_module('xxlimited')
xxlimited_35 = import_helper.import_module('xxlimited_35')


class CommonTests:
module: types.ModuleType

def test_xxo_new(self):
xxo = self.module.Xxo()

def test_xxo_attributes(self):
xxo = self.module.Xxo()
# if import of xxlimited succeeded, the other ones should be importable.
import xxlimited_3_13
import xxlimited_35

MODULES = {
(3, 15): xxlimited,
(3, 13): xxlimited_3_13,
(3, 5): xxlimited_35,
}

def test_with_xxlimited_modules(since=None, until=None):
def _decorator(func):
def _wrapper(self, *args, **kwargs):
for version, module in MODULES.items():
if since and version < since:
continue
if until and version >= until:
continue
with self.subTest(version=version):
func(self, module, *args, **kwargs)
return _wrapper
return _decorator

class XXLimitedTests(unittest.TestCase):
@test_with_xxlimited_modules()
def test_xxo_new(self, module):
xxo = module.Xxo()

@test_with_xxlimited_modules()
def test_xxo_attributes(self, module):
xxo = module.Xxo()
with self.assertRaises(AttributeError):
xxo.foo
with self.assertRaises(AttributeError):
Expand All@@ -26,40 +47,46 @@ def test_xxo_attributes(self):
with self.assertRaises(AttributeError):
xxo.foo

def test_foo(self):
@test_with_xxlimited_modules()
def test_foo(self, module):
# the foo function adds 2 numbers
self.assertEqual(self.module.foo(1, 2), 3)
self.assertEqual(module.foo(1, 2), 3)

def test_str(self):
self.assertIsSubclass(self.module.Str, str)
self.assertIsNot(self.module.Str, str)
@test_with_xxlimited_modules()
def test_str(self, module):
self.assertIsSubclass(module.Str, str)
self.assertIsNot(module.Str, str)

custom_string =self.module.Str("abcd")
custom_string = module.Str("abcd")
self.assertEqual(custom_string, "abcd")
self.assertEqual(custom_string.upper(), "ABCD")

def test_new(self):
xxo = self.module.new()
@test_with_xxlimited_modules()
def test_new(self, module):
xxo = module.new()
self.assertEqual(xxo.demo("abc"), "abc")


class TestXXLimited(CommonTests, unittest.TestCase):
module = xxlimited

def test_xxo_demo(self):
xxo = self.module.Xxo()
other = self.module.Xxo()
@test_with_xxlimited_modules()
def test_xxo_demo(self, module):
xxo = module.Xxo()
self.assertEqual(xxo.demo("abc"), "abc")
self.assertEqual(xxo.demo(0), None)

@test_with_xxlimited_modules(since=(3, 13))
def test_xxo_demo_extra(self, module):
xxo = module.Xxo()
other = module.Xxo()
self.assertEqual(xxo.demo(xxo), xxo)
self.assertEqual(xxo.demo(other), other)
self.assertEqual(xxo.demo(0), None)

def test_error(self):
with self.assertRaises(self.module.Error):
raise self.module.Error
@test_with_xxlimited_modules(since=(3, 13))
def test_error(self, module):
with self.assertRaises(module.Error):
raise module.Error

def test_buffer(self):
xxo = self.module.Xxo()
@test_with_xxlimited_modules(since=(3, 13))
def test_buffer(self, module):
xxo = module.Xxo()
self.assertEqual(xxo.x_exports, 0)
b1 = memoryview(xxo)
self.assertEqual(xxo.x_exports, 1)
Expand All@@ -69,21 +96,13 @@ def test_buffer(self):
self.assertEqual(b1[0], 1)
self.assertEqual(b2[0], 1)


class TestXXLimited35(CommonTests, unittest.TestCase):
module = xxlimited_35

def test_xxo_demo(self):
xxo = self.module.Xxo()
other = self.module.Xxo()
self.assertEqual(xxo.demo("abc"), "abc")
self.assertEqual(xxo.demo(0), None)

@test_with_xxlimited_modules(until=(3, 5))
def test_roj(self):
# the roj function always fails
with self.assertRaises(SystemError):
self.module.roj(0)

@test_with_xxlimited_modules(until=(3, 5))
def test_null(self):
null1 = self.module.Null()
null2 = self.module.Null()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp