- with no_lingering_errors(), test_tempdir('bup-tbloom-') as tmpdir:
- hashes = [os.urandom(20) for i in range(100)]
- class Idx:
- pass
- ix = Idx()
- ix.name='dummy.idx'
- ix.shatable = ''.join(hashes)
- for k in (4, 5):
- b = bloom.create(tmpdir + '/pybuptest.bloom', expected=100, k=k)
- b.add_idx(ix)
- WVPASSLT(b.pfalse_positive(), .1)
- b.close()
- b = bloom.ShaBloom(tmpdir + '/pybuptest.bloom')
- all_present = True
- for h in hashes:
- all_present &= b.exists(h)
- WVPASS(all_present)
- false_positives = 0
- for h in [os.urandom(20) for i in range(1000)]:
- if b.exists(h):
- false_positives += 1
- WVPASSLT(false_positives, 5)
- os.unlink(tmpdir + '/pybuptest.bloom')
+ with no_lingering_errors():
+ with test_tempdir('bup-tbloom-') as tmpdir:
+ hashes = [os.urandom(20) for i in range(100)]
+ class Idx:
+ pass
+ ix = Idx()
+ ix.name='dummy.idx'
+ ix.shatable = ''.join(hashes)
+ for k in (4, 5):
+ b = bloom.create(tmpdir + '/pybuptest.bloom', expected=100, k=k)
+ b.add_idx(ix)
+ WVPASSLT(b.pfalse_positive(), .1)
+ b.close()
+ b = bloom.ShaBloom(tmpdir + '/pybuptest.bloom')
+ all_present = True
+ for h in hashes:
+ all_present &= b.exists(h)
+ WVPASS(all_present)
+ false_positives = 0
+ for h in [os.urandom(20) for i in range(1000)]:
+ if b.exists(h):
+ false_positives += 1
+ WVPASSLT(false_positives, 5)
+ os.unlink(tmpdir + '/pybuptest.bloom')