Skip to content

Commit a728a1b

Browse files
committed
address review: add complex test to test_compare_equal()
1 parent 43e9b18 commit a728a1b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/test/test_memoryview.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,18 @@ def check_equal(view, is_equal):
636636
m = memoryview(a)
637637
check_equal(m, True)
638638

639+
# Test complex formats
640+
for complex_format in 'FD':
641+
with self.subTest(format=complex_format):
642+
data = struct.pack(complex_format * 3, 1.0, 2.0, float('nan'))
643+
m = memoryview(data).cast(complex_format)
644+
# nan is not equal to nan
645+
check_equal(m, False)
646+
647+
data = struct.pack(complex_format * 3, 1.0, 2.0, 3.0)
648+
m = memoryview(data).cast(complex_format)
649+
check_equal(m, True)
650+
639651

640652
class BytesMemorySliceTest(unittest.TestCase,
641653
BaseMemorySliceTests, BaseBytesMemoryTests):

0 commit comments

Comments
 (0)