[Python-checkins] Improve test suite customization example (GH-3967)

Berker Peksag webhook-mailer at python.org
Thu Oct 12 23:42:01 EDT 2017


https://github.com/python/cpython/commit/925510449984399cf58711843ddfe2e8007c3878
commit: 925510449984399cf58711843ddfe2e8007c3878
branch: master
author: Berker Peksag <berker.peksag at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-10-13T06:41:57+03:00
summary:

Improve test suite customization example (GH-3967)

Reported by John Gamboa on docs at p.o at
https://mail.python.org/pipermail/docs/2017-June/031942.html

files:
M Doc/library/unittest.rst

diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst
index 2099bd1e2e9..e52f140029c 100644
--- a/Doc/library/unittest.rst
+++ b/Doc/library/unittest.rst
@@ -402,10 +402,14 @@ you can do it yourself::
 
    def suite():
        suite = unittest.TestSuite()
-       suite.addTest(WidgetTestCase('test_default_size'))
-       suite.addTest(WidgetTestCase('test_resize'))
+       suite.addTest(WidgetTestCase('test_default_widget_size'))
+       suite.addTest(WidgetTestCase('test_widget_resize'))
        return suite
 
+   if __name__ == '__main__':
+       runner = unittest.TextTestRunner()
+       runner.run(suite())
+
 You can place the definitions of test cases and test suites in the same modules
 as the code they are to test (such as :file:`widget.py`), but there are several
 advantages to placing the test code in a separate module, such as



More information about the Python-checkins mailing list