[Zope-CVS] CVS: PythonNet/tests/python - profile.py:1.1 test_array.py:1.2 test_class.py:1.5

Brian Lloyd brian at zope.com
Tue Sep 30 19:54:13 EDT 2003


Update of /cvs-repository/PythonNet/tests/python
In directory cvs.zope.org:/tmp/cvs-serv10541/tests/python

Modified Files:
	test_array.py test_class.py 
Added Files:
	profile.py 
Log Message:
Checkin stuff done in last few weeks (add nunit, iterator support)


=== Added File PythonNet/tests/python/profile.py ===
"""Run all of the unit tests for this package over and over,
   in order to provide for better profiling."""

def main():

    import time
    start = time.clock()

    for i in range(200):
        for name in (
            'test_module',
            'test_conversion',
            'test_class',
            'test_interface',
            'test_enum',
            'test_field',
            'test_property',
            'test_indexer',
            'test_event',
            'test_method',
            'test_delegate',
            'test_array',
            ):
            module = __import__(name)
            module.main()

    stop = time.clock()
    took = str(stop - start)
    print 'Total Time: %s' % took


if __name__ == '__main__':
    main()




=== PythonNet/tests/python/test_array.py 1.1 => 1.2 ===
--- PythonNet/tests/python/test_array.py:1.1	Mon Jul 28 22:28:26 2003
+++ PythonNet/tests/python/test_array.py	Tue Sep 30 19:54:13 2003
@@ -845,6 +845,37 @@
         self.failUnlessRaises(TypeError, test)
 
 
+    def testNullArray(self):
+        """Test null arrays."""
+        object = Test.NullArrayTest()
+        items = object.items
+
+        self.failUnless(len(items) == 5)
+        
+        self.failUnless(items[0] == None)
+        self.failUnless(items[4] == None)
+
+        items[0] = "spam"
+        self.failUnless(items[0] == "spam")
+
+        items[0] = None
+        self.failUnless(items[0] == None)
+
+        items[-4] = "spam"
+        self.failUnless(items[-4] == "spam")
+
+        items[-1] = None
+        self.failUnless(items[-1] == None)
+
+        empty = object.empty
+        self.failUnless(len(empty) == 0)
+
+        def test():
+            object = Test.NullArrayTest()
+            v = object.items["wrong"]
+
+        self.failUnlessRaises(TypeError, test)
+
 
     def testInterfaceArray(self):
         """Test interface arrays."""
@@ -1007,6 +1038,24 @@
             object[0, 0] = "wrong"
 
         self.failUnlessRaises(TypeError, test)
+
+
+    def testArrayIteration(self):
+        """Test array iteration."""
+        items = Test.Int32ArrayTest().items
+
+        for i in items:
+            self.failUnless((i > -1) and (i < 5))
+
+        items = Test.NullArrayTest().items
+
+        for i in items:
+            self.failUnless(i == None)
+
+        empty = Test.NullArrayTest().empty
+
+        for i in empty:
+            raise TypeError, 'iteration over empty array'
 
 
     def testArrayAbuse(self):


=== PythonNet/tests/python/test_class.py 1.4 => 1.5 ===
--- PythonNet/tests/python/test_class.py:1.4	Fri Aug  8 23:29:52 2003
+++ PythonNet/tests/python/test_class.py	Tue Sep 30 19:54:13 2003
@@ -12,6 +12,7 @@
 from CLR.System.Collections import Hashtable
 from CLR.Python.Test import ClassTest
 import sys, os, string, unittest, types
+import CLR.Python.Test as Test
 import CLR.System as System
 
 
@@ -85,6 +86,21 @@
     # test weird metatype
     # test recursion
     # test 
+
+
+    def testIEnumerableIteration(self):
+        """Test iteration over objects supporting IEnumerable."""
+        list = Test.ClassTest.GetArrayList()
+
+        for item in list:
+            self.failUnless((item > -1) and (item < 10))
+
+        dict = Test.ClassTest.GetHashtable()
+
+        for item in dict:
+            cname = item.__class__.__name__
+            self.failUnless(cname.endswith('DictionaryEntry'))
+
 
     def testOverrideGetItem(self):
         """Test managed subclass overriding __getitem__."""




More information about the Zope-CVS mailing list