Index: pythontest2.py
===================================================================
--- pythontest2.py	(revision 13795)
+++ pythontest2.py	(working copy)
@@ -1331,6 +1331,21 @@
     expect(ranges.get_values_seen(), 3)
     expect(ranges.get_ranges_as_dict(), {(1.5, 2): 3})
 
+def test_lazydocument():
+    """Test the lazy document loading and modification code.
+
+    """
+    dbpath = 'db_test_lazydocument'
+    db=xapian.WritableDatabase(dbpath, xapian.DB_CREATE_OR_OVERWRITE)
+    db.add_document(xapian.Document())
+    doc1=db.get_document(1)
+    doc2=db.get_document(1)
+    doc1.add_term('foo')
+    db.replace_document(1, doc1)
+    expect([t.term for t in db.get_document(1).termlist()], ['foo'])
+    db.replace_document(1, doc2)
+    expect([t.term for t in db.get_document(1).termlist()], [])
+
 # Run all tests (ie, callables with names starting "test_").
 if not runtests(globals(), sys.argv[1:]):
     sys.exit(1)
