[Zope3-checkins] CVS: ZODB4/src/zodb/storage/tests - base.py:1.3

Barry Warsaw barry@wooz.org
Wed, 22 Jan 2003 14:45:00 -0500


Update of /cvs-repository/ZODB4/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv12312

Modified Files:
	base.py 
Log Message:
Remove some unnecessary and redundant imports, rearranged others.

Get ZERO from zodb.storage.base

Rewrite zodb_pickle() in terms of ObjectWriter.


=== ZODB4/src/zodb/storage/tests/base.py 1.2 => 1.3 ===
--- ZODB4/src/zodb/storage/tests/base.py:1.2	Wed Dec 25 09:12:20 2002
+++ ZODB4/src/zodb/storage/tests/base.py	Wed Jan 22 14:44:58 2003
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2001 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -20,35 +20,26 @@
 single object revision.
 """
 
-import errno
 import os
-import string
 import sys
+import errno
 import types
 import unittest
-from cPickle import Pickler, Unpickler
-from cStringIO import StringIO
 
-from zodb.serialize import ConnectionObjectReader
-from zodb.ztransaction import Transaction
+from transaction import get_transaction
 
+from zodb.db import DB
+from zodb.serialize import ConnectionObjectReader, ObjectWriter
+from zodb.ztransaction import Transaction
 from zodb.storage.tests.minpo import MinPO
+from zodb.storage.base import ZERO, BerkeleyConfig
 
-ZERO = '\0'*8
 DBHOME = 'test-db'
 
 
 def zodb_pickle(obj):
     """Create a pickle in the format expected by ZODB."""
-    f = StringIO()
-    p = Pickler(f, 1)
-    klass = obj.__class__
-    mod = getattr(klass, "__module__", None)
-    state = obj.__getstate__()
-    # XXX
-    p.dump((mod, klass.__name__, None))
-    p.dump(state)
-    return f.getvalue(1)
+    return ObjectWriter(obj._p_jar).getState(obj)
 
 def zodb_unpickle(data):
     """Unpickle an object stored using the format expected by ZODB."""
@@ -200,23 +191,6 @@
         self._storage.tpc_vote(t)
         self._storage.tpc_finish(t)
         return oids
-
-
-# Base class for unit tests at the ZODB layer
-
-import os
-import errno
-
-from zodb.db import DB
-from transaction import get_transaction
-
-
-# Basic test framework class for both the Full and Minimal Berkeley storages
-
-import os
-import errno
-
-from zodb.storage.base import BerkeleyConfig