Skip to content

Commit 5547af4

Browse files
committed
chore: resolve comment issue
1 parent b2207aa commit 5547af4

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

Lib/test/test_queue.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,18 +1010,11 @@ class C:
10101010
self.assertIsNone(wr())
10111011

10121012
def test_sizeof(self):
1013-
# Test that __sizeof__() accounts for underlying data structure
10141013
q = self.q
10151014

1016-
# Get the size of an empty queue
10171015
empty_size = q.__sizeof__()
10181016
self.assertGreater(empty_size, 0, "Empty queue should have non-zero size")
10191017

1020-
# Size should include basic object structure
1021-
# For C implementation, this includes the ring buffer array
1022-
# For Python implementation, this includes the underlying deque
1023-
1024-
# Add items within initial capacity (if applicable)
10251018
for i in range(8):
10261019
q.put(object())
10271020

@@ -1034,8 +1027,7 @@ def test_sizeof(self):
10341027
q.put(object()) # Now 9 items
10351028

10361029
size_after_9 = q.__sizeof__()
1037-
self.assertGreaterEqual(size_after_9, size_after_8,
1038-
"Size should not decrease when adding items")
1030+
self.assertGreaterEqual(size_after_9, size_after_8)
10391031

10401032
# Test with a larger number of items
10411033
large_q = self.type2test()
@@ -1070,6 +1062,22 @@ def setUp(self):
10701062
self.type2test = self.queue._PySimpleQueue
10711063
super().setUp()
10721064

1065+
def test_equality(self):
1066+
# Test that SimpleQueue uses object identity, not value equality
1067+
q1 = self.type2test()
1068+
q2 = self.type2test()
1069+
1070+
# Different instances should not be equal
1071+
self.assertNotEqual(q1, q2)
1072+
1073+
# Same instance should be equal to itself
1074+
self.assertEqual(q1, q1)
1075+
1076+
# Even with same content, instances should not be equal
1077+
q1.put('test')
1078+
q2.put('test')
1079+
self.assertNotEqual(q1, q2)
1080+
10731081

10741082
@need_c_queue
10751083
class CSimpleQueueTest(BaseSimpleQueueTest, unittest.TestCase):
@@ -1084,6 +1092,22 @@ def test_is_default(self):
10841092
self.assertIs(self.type2test, self.queue.SimpleQueue)
10851093
self.assertIs(self.type2test, self.queue.SimpleQueue)
10861094

1095+
def test_equality(self):
1096+
# Test that SimpleQueue uses object identity, not value equality
1097+
q1 = self.type2test()
1098+
q2 = self.type2test()
1099+
1100+
# Different instances should not be equal
1101+
self.assertNotEqual(q1, q2)
1102+
1103+
# Same instance should be equal to itself
1104+
self.assertEqual(q1, q1)
1105+
1106+
# Even with same content, instances should not be equal
1107+
q1.put('test')
1108+
q2.put('test')
1109+
self.assertNotEqual(q1, q2)
1110+
10871111
def test_reentrancy(self):
10881112
# bpo-14976: put() may be called reentrantly in an asynchronous
10891113
# callback.

0 commit comments

Comments
 (0)