[Zope-Checkins] CVS: ZODB3/ZODB/tests - util.py:1.1.2.1

Jim Fulton jim at zope.com
Fri Jan 16 10:43:24 EST 2004


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv18997/src/ZODB/tests

Added Files:
      Tag: zope3-zodb3-devel-branch
	util.py 
Log Message:
Ported the zodb 4 testing utility package.
This makes writing tests much easier.  It's also handy
for playing interactively.


=== Added File ZODB3/ZODB/tests/util.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Conventience function for creating test databases

$Id: util.py,v 1.1.2.1 2004/01/16 15:43:24 jim Exp $
"""

import time
import persistent
from ZODB.DemoStorage import DemoStorage
from ZODB.DB import DB as _DB
from transaction import get_transaction

def DB(name='Test'):
    return _DB(DemoStorage(name))

def commit():
    get_transaction().commit()

def pack(db):
    db.pack(time.time()+1)

class P(persistent.Persistent):
    
    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return 'P(%s)' % self.name




More information about the Zope-Checkins mailing list