Message217407
Hi Antoine,
I have no found a way to check resource usage in test infrastructure and I don't think it could be done carefully. The only method I found to test issue is straightforward: just to check source iterator is not referenced from itertools.islice() after the latter has been exhausted:
================================================
a = [random.random() for i in range(10)]
before = sys.getrefcount(a)
b = islice(a, 5)
for i in b: pass
after = sys.getrefcount(a)
self.assertEqual(before, after)
================================================
Attaching "issue21321_2.7_e3217efa6edd_3.diff" and "issue21321_3.4_8c8315bac6a8_3.diff" patches with this test included in "Lib/test/test_itertools.py". |
|
Date |
User |
Action |
Args |
2014-04-28 19:47:57 | Anton.Afanasyev | set | recipients:
+ Anton.Afanasyev, rhettinger, pitrou |
2014-04-28 19:47:57 | Anton.Afanasyev | set | messageid: <1398714477.7.0.844701459634.issue21321@psf.upfronthosting.co.za> |
2014-04-28 19:47:57 | Anton.Afanasyev | link | issue21321 messages |
2014-04-28 19:47:57 | Anton.Afanasyev | create | |
|