[Zope-CVS] CVS: PythonNet/tests/python - test_class.py:1.3
Brian Lloyd
brian at zope.com
Fri Aug 8 16:49:32 EDT 2003
Update of /cvs-repository/PythonNet/tests/python
In directory cvs.zope.org:/tmp/cvs-serv22496/tests/python
Modified Files:
test_class.py
Log Message:
checkpoint
=== PythonNet/tests/python/test_class.py 1.2 => 1.3 ===
--- PythonNet/tests/python/test_class.py:1.2 Sat Aug 2 17:55:34 2003
+++ PythonNet/tests/python/test_class.py Fri Aug 8 15:49:26 2003
@@ -63,6 +63,31 @@
"""Test basic subclass of a managed class."""
class MyTable(Hashtable):
+ def howMany(self):
+ return self.Count
+
+ table = MyTable()
+
+ self.failUnless(table.__class__.__name__.endswith('MyTable'))
+ self.failUnless(type(table).__name__.endswith('MyTable'))
+ self.failUnless(len(table.__class__.__bases__) == 1)
+ self.failUnless(table.__class__.__bases__[0] == Hashtable)
+
+ self.failUnless(table.howMany() == 0)
+ self.failUnless(table.Count == 0)
+
+ #table['one'] = ['one']
+ #table.set_Item('one', 'one')
+ Hashtable.__setitem__(table, 'one', 'one')
+
+ self.failUnless(table.howMany() == 1)
+ self.failUnless(table.Count == 1)
+
+
+ def testOverrideGetItem(self):
+ """Test managed subclass overriding __getitem__."""
+
+ class MyTable(Hashtable):
def __getitem__(self, key):
value = Hashtable.__getitem__(self, key)
@@ -74,6 +99,31 @@
table['three'] = 'three'
self.failUnless(table['one'] == 'my one')
+ self.failUnless(table['two'] == 'my two')
+ self.failUnless(table['three'] == 'my three')
+
+ self.failUnless(table.Count == 3)
+
+
+ def testOverrideSetItem(self):
+ """Test managed subclass overriding __setitem__."""
+
+ class MyTable(Hashtable):
+
+ def __setitem__(self, key, value):
+ value = 'my ' + str(value)
+ Hashtable.__setitem__(self, key, value)
+
+
+ table = MyTable()
+ table['one'] = 'one'
+ table['two'] = 'two'
+ table['three'] = 'three'
+
+ self.failUnless(table['one'] == 'my one')
+ self.failUnless(table['two'] == 'my two')
+ self.failUnless(table['three'] == 'my three')
+
self.failUnless(table.Count == 3)
More information about the Zope-CVS
mailing list