Serhiy Storchaka added the comment:
> Additionally, the "more specific tests" introduce some additional opacity
> that is harmful for knowing what methods and operators are specifically
> used internally in test method. For end users of Python, they don't have
> to worry much about this, but we as developers of core types really care
> whether self.assertLessThan(x, y) really does x < y, or x.__lt__(y), or
> "not y >= x", etc.
If the test explicitly designed to test relation or boolean operations, I
leave it as is. I try to be very careful.
After more careful reviewing this patch, I have found than some tests
shouldn't be changed, because they produce utterly large error message in case
of a failure (even if resulted message is truncated, as in case of
assertEqual, large intermediate strings are created). Here is corrected patch.
----------
Added file: http://bugs.python.org/file34079/test_bigmem_asserts_2.patch
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20547>
_______________________________________
diff -r 0f357cf011d3 Lib/test/test_bigmem.py
--- a/Lib/test/test_bigmem.py Thu Feb 13 10:49:30 2014 +0200
+++ b/Lib/test/test_bigmem.py Fri Feb 14 13:47:49 2014 +0200
@@ -866,7 +866,7 @@
h1 = hash(t1)
del t1
t2 = (0,) * (size + 1)
- self.assertFalse(h1 == hash(t2))
+ self.assertNotEqual(h1, hash(t2))
@bigmemtest(size=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
@@ -992,8 +992,8 @@
l = [sys.stdout] * size
l += l
self.assertEqual(len(l), size * 2)
- self.assertTrue(l[0] is l[-1])
- self.assertTrue(l[size - 1] is l[size + 1])
+ self.assertIs(l[0], l[-1])
+ self.assertIs(l[size - 1], l[size + 1])
@bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_inplace_concat_small(self, size):
@@ -1092,13 +1092,13 @@
l = ['']
l *= size
self.assertEqual(len(l), size)
- self.assertTrue(l[0] is l[-1])
+ self.assertIs(l[0], l[-1])
del l
l = [''] * size
l *= 2
self.assertEqual(len(l), size * 2)
- self.assertTrue(l[size - 1] is l[-1])
+ self.assertIs(l[size - 1], l[-1])
@bigmemtest(size=_2G // 2 + 2, memuse=16)
def test_inplace_repeat_small(self, size):
@@ -1132,8 +1132,8 @@
l = [object()] * size
l.append(object())
self.assertEqual(len(l), size+1)
- self.assertTrue(l[-3] is l[-2])
- self.assertFalse(l[-2] is l[-1])
+ self.assertIs(l[-3], l[-2])
+ self.assertIsNot(l[-2], l[-1])
@bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_count(self, size):
@@ -1145,8 +1145,8 @@
l = [object] * size
l.extend(l)
self.assertEqual(len(l), size * 2)
- self.assertTrue(l[0] is l[-1])
- self.assertTrue(l[size - 1] is l[size + 1])
+ self.assertIs(l[0], l[-1])
+ self.assertIs(l[size - 1], l[size + 1])
@bigmemtest(size=_2G // 2 + 2, memuse=16)
def test_extend_small(self, size):
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com