Ticket #421: lazymodproblem.patch

File lazymodproblem.patch, 940 bytes (added by Richard Boulton, 15 years ago)

Patch to add testcase to the python testsuite which demonstrates this.

  • pythontest2.py

     
    13311331    expect(ranges.get_values_seen(), 3)
    13321332    expect(ranges.get_ranges_as_dict(), {(1.5, 2): 3})
    13331333
     1334def test_lazydocument():
     1335    """Test the lazy document loading and modification code.
     1336
     1337    """
     1338    dbpath = 'db_test_lazydocument'
     1339    db=xapian.WritableDatabase(dbpath, xapian.DB_CREATE_OR_OVERWRITE)
     1340    db.add_document(xapian.Document())
     1341    doc1=db.get_document(1)
     1342    doc2=db.get_document(1)
     1343    doc1.add_term('foo')
     1344    db.replace_document(1, doc1)
     1345    expect([t.term for t in db.get_document(1).termlist()], ['foo'])
     1346    db.replace_document(1, doc2)
     1347    expect([t.term for t in db.get_document(1).termlist()], [])
     1348
    13341349# Run all tests (ie, callables with names starting "test_").
    13351350if not runtests(globals(), sys.argv[1:]):
    13361351    sys.exit(1)