[Zope3-checkins] CVS: Zope3/src/zope/app/schemagen/tests - test_typereg.py:1.1.2.3
Fred L. Drake, Jr.
fred@zope.com
Tue, 24 Dec 2002 12:10:16 -0500
Update of /cvs-repository/Zope3/src/zope/app/schemagen/tests
In directory cvs.zope.org:/tmp/cvs-serv10570
Modified Files:
Tag: NameGeddon-branch
test_typereg.py
Log Message:
- straighten out the imports
- normalize whitespace
=== Zope3/src/zope/app/schemagen/tests/test_typereg.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/schemagen/tests/test_typereg.py:1.1.2.2 Tue Dec 24 07:51:15 2002
+++ Zope3/src/zope/app/schemagen/tests/test_typereg.py Tue Dec 24 12:10:16 2002
@@ -15,19 +15,19 @@
$Id$
"""
-from unittest import TestCase, makeSuite, TestSuite
import datetime
+import unittest
from zope.app.schemagen.typereg import TypeRepresentationRegistry,\
DefaultTypeRepresentation, DatetimeRepresentation,\
DefaultFieldRepresentation
-from Zope import Schema
+from zope import schema
from zope.schema.interfaces import IField
-from zope.schema import Field, Text, Int
-class DefaultTypeRepresentationTests(TestCase):
+
+class DefaultTypeRepresentationTests(unittest.TestCase):
def test_getTypes(self):
c = DefaultTypeRepresentation
self.assertEquals((), tuple(c.getTypes()))
@@ -35,7 +35,7 @@
def h(self, obj):
r = DefaultTypeRepresentation(obj)
self.assertEquals(eval(r.text), obj)
-
+
def h_builtin(self, obj):
r = DefaultTypeRepresentation(obj)
self.assertEquals(eval(r.text), obj)
@@ -53,7 +53,7 @@
{'foo':'bar', 'baz':'hoi'},
{'foo': (1, "foo")}
]
-
+
def test_builtins(self):
for builtin_instance in self.builtin_instances:
self.h_builtin(builtin_instance)
@@ -65,7 +65,7 @@
r = DefaultTypeRepresentation(recursive)
self.assertRaises(SyntaxError, eval, r.text)
-class DatetimeRepresentationTests(TestCase):
+class DatetimeRepresentationTests(unittest.TestCase):
datetime_instances = [
(datetime.date(2002, 10, 30),
@@ -75,7 +75,7 @@
(datetime.time(10, 0, 1),
[('datetime', 'time')]),
]
-
+
def test_date(self):
for datetime_instance, import_list in self.datetime_instances:
r = DatetimeRepresentation(datetime_instance)
@@ -92,14 +92,14 @@
import_dict[import_from] = getattr(module, import_from)
return eval(r.text, import_dict)
-class TypeRepresentationRegistryTests(TestCase):
+class TypeRepresentationRegistryTests(unittest.TestCase):
def setUp(self):
self.tr = TypeRepresentationRegistry(DefaultTypeRepresentation)
def test_default(self):
self.assert_(isinstance(
self.tr.represent(1), DefaultTypeRepresentation))
-
+
def test_register(self):
from zope.app.interfaces.schemagen import ITypeRepresentation
class IntRepresentation:
@@ -113,7 +113,7 @@
importList = []
text = ''
-
+
self.tr.register(IntRepresentation)
self.assert_(isinstance(self.tr.represent(1), IntRepresentation))
@@ -123,12 +123,12 @@
class IFieldSchema(IField):
# the greek alphabet is not in alphabetical order, so we cannot
# depend on ascii sort order, which is good as we shouldn't.
- alpha = Text(title=u"Alpha", default=u"")
- beta = Int(title=u"Beta", default=0)
- gamma = Text(title=u"Gamma", default=u"")
- delta = Int(title=u"Delta", default=0)
+ alpha = schema.Text(title=u"Alpha", default=u"")
+ beta = schema.Int(title=u"Beta", default=0)
+ gamma = schema.Text(title=u"Gamma", default=u"")
+ delta = schema.Int(title=u"Delta", default=0)
-class MyField(Field):
+class MyField(schema.Field):
__implements__ = IFieldSchema
def __init__(self, alpha=u'', beta=0, gamma=u'', delta=0, **kw):
@@ -137,23 +137,23 @@
self.beta = beta
self.gamma = gamma
self.delta = delta
-
-class DefaultFieldRepresentationTests(TestCase):
+
+class DefaultFieldRepresentationTests(unittest.TestCase):
# XXX there is an issue with field classes which have the same name
# multiple 'from x import y' statements will cause one name to be
# shadowed by another. We can't test for this yet.
schema_fields = [
- (Schema.Text(title=u"text"),
+ (schema.Text(title=u"text"),
[('zope.schema', 'Text')]),
- (Schema.Int(title=u"int"),
+ (schema.Int(title=u"int"),
[('zope.schema', 'Int')]),
- (Schema.TextLine(title=u"text"),
+ (schema.TextLine(title=u"text"),
[('zope.schema', 'TextLine')]),
- (Schema.Float(title=u"float"),
+ (schema.Float(title=u"float"),
[('zope.schema', 'Float')])
]
-
+
def test_field(self):
for field, import_list in self.schema_fields:
r = DefaultFieldRepresentation(field)
@@ -174,11 +174,13 @@
self.assertNotEquals(g, -1)
self.assertNotEquals(d, -1)
self.assert_(a < g < d)
-
+
def test_suite():
- return TestSuite(
- (makeSuite(DefaultTypeRepresentationTests),
- makeSuite(DatetimeRepresentationTests),
- makeSuite(TypeRepresentationRegistryTests),
- makeSuite(DefaultFieldRepresentationTests),
- ))
+ suite = unittest.makeSuite(DefaultTypeRepresentationTests)
+ suite.addTest(unittest.makeSuite(DatetimeRepresentationTests))
+ suite.addTest(unittest.makeSuite(TypeRepresentationRegistryTests))
+ suite.addTest(unittest.makeSuite(DefaultFieldRepresentationTests))
+ return suite
+
+if __name__ == "__main__":
+ unittest.main(defaultTest='test_suite')