-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-111495: Add tests for PyList C API #111562
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d43d9b2
init test c file
rawwar 119cd0e
single test added
rawwar ccf1bff
fix lint
rawwar 8d17ca6
fix list check tests
rawwar bd9415d
lint
rawwar 17d60d1
add 2 tests
rawwar 322eab9
add test
rawwar 5c58022
add getitem test
rawwar 6b12f1f
test list_get_item
rawwar 70e385f
add test for setitem
rawwar 3166ba4
add test for setitem
rawwar 2a50fb8
Merge branch 'kalyan/test-capi-list' of github.com:rawwar/cpython int…
rawwar 1c30f3b
Merge branch 'main' of github.com:rawwar/cpython into kalyan/test-cap…
rawwar 392b3c6
add tests
rawwar eac8c67
lint fix
rawwar 0f40f6d
add tests
rawwar 40e4022
Update Lib/test/test_capi/test_list.py
rawwar d31fa57
Update Modules/_testcapi/list.c
rawwar 433351d
Update Lib/test/test_capi/test_list.py
rawwar 34e915b
Update Lib/test/test_capi/test_list.py
rawwar 0e340a1
pr feedback fixes
rawwar 8de9cf8
fixes for the feedback
rawwar 44dcf85
add tests from vstinner PR
rawwar 1000126
Merge branch 'main' into kalyan/test-capi-list
rawwar 2c6a41c
remove unused import
rawwar e486451
Update list.c
rawwar 633951b
Merge branch 'main' into kalyan/test-capi-list
rawwar 9afa50c
Merge branch 'main' into kalyan/test-capi-list
rawwar 361b045
Merge branch 'main' into kalyan/test-capi-list
rawwar ca07ac9
Update Modules/_testcapi/list.c
vstinner dc039f1
Update Modules/_testcapi/list.c
vstinner 5ecfa40
Merge branch 'main' into kalyan/test-capi-list
serhiy-storchaka 42a2a54
Minor fixes.
serhiy-storchaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add 2 tests
- Loading branch information
commit 17d60d15c8c47a29a3a15e1588938b7e0e20402b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
import unittest | ||
import sys | ||
from test.support import import_helper | ||
from collections import UserList | ||
|
||
_testcapi = import_helper.import_module('_testcapi') | ||
|
||
NULL = None | ||
|
||
class ListSubclass(list): | ||
... | ||
|
||
class CAPITest(unittest.TestCase): | ||
def test_check(self): | ||
# Test PyList_Check() | ||
rawwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
check = _testcapi.list_check | ||
self.assertTrue(check([1, 2])) | ||
self.assertTrue(check([])) | ||
self.assertTrue(check(ListSubclass([1, 2]))) | ||
self.assertFalse(check({1: 2})) | ||
self.assertFalse(check((1, 2))) | ||
self.assertFalse(check('abc')) | ||
self.assertFalse(check(b'abc')) | ||
self.assertFalse(check(42)) | ||
self.assertFalse(check(object())) | ||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def test_list_check_exact(self): | ||
check = _testcapi.list_check_exact | ||
self.assertTrue(check([1])) | ||
self.assertTrue(check([])) | ||
self.assertFalse(check(ListSubclass([1]))) | ||
self.assertFalse(check(UserList([1, 2]))) | ||
self.assertFalse(check({1: 2})) | ||
self.assertFalse(check(object())) | ||
|
||
def test_list_new(self): | ||
rawwar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
list_new = _testcapi.list_new | ||
lst = list_new() | ||
self.assertEqual(lst, []) | ||
self.assertIs(type(lst), list) | ||
lst2 = list_new() | ||
self.assertIsNot(lst2, lst) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.