-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Based on python/core-workflow#505
Source:
cpython/Lib/test/test_buffer.py
Lines 4697 to 4754 in bbf722d
| 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
Linked PRs
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error