]> granicus.if.org Git - python/commitdiff
Added an __iter__ method for test suites.
authorJim Fulton <jim@zope.com>
Sat, 28 Aug 2004 15:22:12 +0000 (15:22 +0000)
committerJim Fulton <jim@zope.com>
Sat, 28 Aug 2004 15:22:12 +0000 (15:22 +0000)
Lib/test/test_unittest.py [new file with mode: 0644]
Lib/unittest.py

diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
new file mode 100644 (file)
index 0000000..9151166
--- /dev/null
@@ -0,0 +1,31 @@
+"""Test script for unittest.
+
+This just includes tests for new features.  We really need a
+full set of tests.
+"""
+
+import unittest
+
+def test_TestSuite_iter():
+    """
+    >>> test1 = unittest.FunctionTestCase(lambda: None)
+    >>> test2 = unittest.FunctionTestCase(lambda: None)
+    >>> suite = unittest.TestSuite((test1, test2))
+    >>> tests = []
+    >>> for test in suite:
+    ...     tests.append(test)
+    >>> tests == [test1, test2]
+    True
+    """
+
+
+######################################################################
+## Main
+######################################################################
+
+def test_main():
+    from test import test_support, test_unittest
+    test_support.run_doctest(test_unittest, verbosity=True)
+
+if __name__ == '__main__':
+    test_main()
index 29d90e3bfa9f08e37b7ad3bb5f0ef8f565525679..3375067c8d07643090987db092f10b8e1a9a1931 100644 (file)
@@ -400,6 +400,9 @@ class TestSuite:
 
     __str__ = __repr__
 
+    def __iter__(self):
+        return iter(self._tests)
+
     def countTestCases(self):
         cases = 0
         for test in self._tests: