Skip to content

test_multiple_inheritance_buffer_last is duplicated in test_buffer #106197

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

Closed
sobolevn opened this issue Jun 28, 2023 · 0 comments
Closed

test_multiple_inheritance_buffer_last is duplicated in test_buffer #106197

sobolevn opened this issue Jun 28, 2023 · 0 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Jun 28, 2023

Based on python/core-workflow#505

Source:

def test_multiple_inheritance_buffer_last(self):
class A:
def __buffer__(self, flags):
return memoryview(b"hello A")
class B(A, bytearray):
def __buffer__(self, flags):
return super().__buffer__(flags)
b = B(b"hello")
with memoryview(b) as mv:
self.assertEqual(mv.tobytes(), b"hello A")
class Releaser:
def __release_buffer__(self, buffer):
self.buffer = buffer
class C(Releaser, bytearray):
def __buffer__(self, flags):
return super().__buffer__(flags)
c = C(b"hello C")
with memoryview(c) as mv:
self.assertEqual(mv.tobytes(), b"hello C")
c.clear()
with self.assertRaises(ValueError):
c.buffer.tobytes()
def test_multiple_inheritance_buffer_last(self):
class A:
def __buffer__(self, flags):
raise RuntimeError("should not be called")
def __release_buffer__(self, buffer):
raise RuntimeError("should not be called")
class B(bytearray, A):
def __buffer__(self, flags):
return super().__buffer__(flags)
b = B(b"hello")
with memoryview(b) as mv:
self.assertEqual(mv.tobytes(), b"hello")
class Releaser:
buffer = None
def __release_buffer__(self, buffer):
self.buffer = buffer
class C(bytearray, Releaser):
def __buffer__(self, flags):
return super().__buffer__(flags)
c = C(b"hello")
with memoryview(c) as mv:
self.assertEqual(mv.tobytes(), b"hello")
c.clear()
self.assertIs(c.buffer, None)

There are two different tests with the same name. One must be renamed.

Before: Ran 89 tests in 3.824s
After: Ran 90 tests in 4.576s

CC @JelleZijlstra

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Jun 28, 2023
@sobolevn sobolevn self-assigned this Jun 28, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Jun 28, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 28, 2023
(cherry picked from commit c283a0c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
JelleZijlstra pushed a commit that referenced this issue Jun 28, 2023
…6206)

gh-106197: Deduplicate tests in `test_buffer` (GH-106198)
(cherry picked from commit c283a0c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant