Ticket #317: xaptest.py

File xaptest.py, 524 bytes (added by Richard Boulton, 16 years ago)

Test script

Line 
1#!/usr/bin/env python
2
3import os
4import sys
5import xapian
6
7dbpath = 'testdb'
8
9db = xapian.WritableDatabase(dbpath, xapian.DB_CREATE_OR_OPEN)
10errcount = 0
11
12for a in xrange(0, 100000):
13 doc = xapian.Document()
14 for b in xrange(1000):
15 doc.add_posting(str((a * b) % 1000), b)
16 try:
17 db.add_document(doc)
18 if a % 10 == 0:
19 print a
20 if a % 1000 == 0:
21 db.flush()
22 except Exception, e:
23 print e
24 errcount += 1
25 if errcount >= 2:
26 raise