[Zope3-checkins] CVS: Zope3/lib/python/Persistence/tests - testModule.py:1.15
Jeremy Hylton
jeremy@zope.com
Thu, 18 Jul 2002 18:41:58 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/tests
In directory cvs.zope.org:/tmp/cvs-serv27240/lib/python/Persistence/tests
Modified Files:
testModule.py
Log Message:
First steps towards persistent classes.
Some trivial tests succeed, but there is much work to do.
=== Zope3/lib/python/Persistence/tests/testModule.py 1.14 => 1.15 ===
from Persistence import tests
from Transaction import get_transaction
+from Transaction import get_transaction
+
# snippets of source code used by testModules
foo_src = """\
x = 1
@@ -172,7 +174,31 @@
## closure._p_deactivate()
## self.assertEqual(closure.inc(5), 6)
+ def testClass(self):
+ import pickle
+ self.importer.module_from_source("foo", src)
+ get_transaction().commit()
+ import foo
+ obj = foo.Foo()
+ obj.m()
+ self.root["m"] = obj
+ get_transaction().commit()
+ foo._p_deactivate()
+ o = foo.Foo()
+ i = o.m()
+ j = o.m()
+ self.assertEqual(i + 1, j)
+
+src = """\
+from Persistence.Class import PersistentBaseClass
+
+class Foo(PersistentBaseClass):
+ def __init__(self):
+ self.x = id(self)
+ def m(self):
+ self.x += 1
+ return self.x
+"""
+
def test_suite():
return unittest.makeSuite(TestModule)
-
-