[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/schemagen/tests - setstate.py.txt:1.1 setstatemodule.py.txt:1.1 setstatemodule_no_history.py.txt:1.1 test_schemaspec.py:1.4
Jeremy Hylton
jeremy@zope.com
Thu, 19 Dec 2002 17:40:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/schemagen/tests
In directory cvs.zope.org:/tmp/cvs-serv12801
Modified Files:
test_schemaspec.py
Added Files:
setstate.py.txt setstatemodule.py.txt
setstatemodule_no_history.py.txt
Log Message:
Rename generated files to .txt to support distutils sdist
=== Added File Zope3/lib/python/Zope/App/schemagen/tests/setstate.py.txt ===
def __setstate__(self, state):
transformations = schemaspec.prepareSetstate(self, state, 6)
if transformations is None:
return
dict = self.__dict__
if 0 in transformations:
schemaspec.AddField.update(dict, state, 'alpha')
if 1 in transformations:
schemaspec.RemoveField.update(dict, state, 'alpha')
if 2 in transformations:
schemaspec.AddField.update(dict, state, 'beta')
if 3 in transformations:
schemaspec.InsertField.update(dict, state, 'gamma', 0)
if 4 in transformations:
schemaspec.MoveField.update(dict, state, 'gamma', 2)
if 5 in transformations:
schemaspec.RenameField.update(dict, state, 'gamma', 'gamma2')
=== Added File Zope3/lib/python/Zope/App/schemagen/tests/setstatemodule.py.txt ===
from Interface import Interface
from Persistence import Persistent
from Zope.Schema.FieldProperty import FieldProperty
# field imports
from Zope.Schema import Text
from Zope.App.schemagen import schemaspec
class IFoo(Interface):
"""Autogenerated schema."""
alpha = Text(title=u'alpha')
class FooClass(Persistent):
"""Autogenerated class for IFoo."""
__implements__ = IFoo
def __init__(self):
self.__schema_version__ = 1
alpha = FieldProperty(IFoo['alpha'])
def __setstate__(self, state):
transformations = schemaspec.prepareSetstate(self, state, 1)
if transformations is None:
return
dict = self.__dict__
if 0 in transformations:
schemaspec.AddField.update(dict, state, 'alpha')
=== Added File Zope3/lib/python/Zope/App/schemagen/tests/setstatemodule_no_history.py.txt ===
from Interface import Interface
from Persistence import Persistent
from Zope.Schema.FieldProperty import FieldProperty
# field imports
class IFoo(Interface):
"""Autogenerated schema."""
class FooClass(Persistent):
"""Autogenerated class for IFoo."""
__implements__ = IFoo
def __init__(self):
self.__schema_version__ = 0
=== Zope3/lib/python/Zope/App/schemagen/tests/test_schemaspec.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/schemagen/tests/test_schemaspec.py:1.3 Thu Dec 12 13:54:20 2002
+++ Zope3/lib/python/Zope/App/schemagen/tests/test_schemaspec.py Thu Dec 19 17:40:40 2002
@@ -186,7 +186,7 @@
self.assertEquals(history, s.getHistory())
# check whether generated source is as we expect
- f = openInTests('setstate.py.gen', 'r')
+ f = openInTests('setstate.py.txt', 'r')
source = f.read()
f.close()
self.assertEquals(source, s.generateSetstateSource())
@@ -195,7 +195,7 @@
s = self.s
s.addField('alpha', self.alpha)
- f = openInTests('setstatemodule.py.gen', 'r')
+ f = openInTests('setstatemodule.py.txt', 'r')
source = f.read()
f.close()
self.assertEquals(source, s.generateModuleSource())
@@ -203,7 +203,7 @@
def test_generateModuleSource(self):
s = self.s
# no history, so expect no setstate
- f = openInTests('setstatemodule_no_history.py.gen', 'r')
+ f = openInTests('setstatemodule_no_history.py.txt', 'r')
source = f.read()
f.close()
self.assertEquals(source.strip(), s.generateModuleSource().strip())