Left: | ||
Right: |
OLD | NEW |
---|---|
1 :mod:`unittest` --- Unit testing framework | 1 :mod:`unittest` --- Unit testing framework |
2 ========================================== | 2 ========================================== |
3 | 3 |
4 .. module:: unittest | 4 .. module:: unittest |
5 :synopsis: Unit testing framework for Python. | 5 :synopsis: Unit testing framework for Python. |
6 .. moduleauthor:: Steve Purcell <stephen_purcell@yahoo.com> | 6 .. moduleauthor:: Steve Purcell <stephen_purcell@yahoo.com> |
7 .. sectionauthor:: Steve Purcell <stephen_purcell@yahoo.com> | 7 .. sectionauthor:: Steve Purcell <stephen_purcell@yahoo.com> |
8 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org> | 8 .. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org> |
9 .. sectionauthor:: Raymond Hettinger <python@rcn.com> | 9 .. sectionauthor:: Raymond Hettinger <python@rcn.com> |
10 | 10 |
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 used during the test. Functions will be called in reverse order to the | 1122 used during the test. Functions will be called in reverse order to the |
1123 order they are added (LIFO). They are called with any arguments and | 1123 order they are added (LIFO). They are called with any arguments and |
1124 keyword arguments passed into :meth:`addCleanup` when they are | 1124 keyword arguments passed into :meth:`addCleanup` when they are |
1125 added. | 1125 added. |
1126 | 1126 |
1127 If :meth:`setUp` fails, meaning that :meth:`tearDown` is not called, | 1127 If :meth:`setUp` fails, meaning that :meth:`tearDown` is not called, |
1128 then any cleanup functions added will still be called. | 1128 then any cleanup functions added will still be called. |
1129 | 1129 |
1130 .. versionadded:: 3.2 | 1130 .. versionadded:: 3.2 |
1131 | 1131 |
1132 | 1132 |
Georg
2010/04/10 19:07:56
This change seems to be unrelated.
barry
2010/04/12 21:59:05
Yep, just a drive-by fix that I'll land separately
| |
1133 .. method:: doCleanups() | 1133 .. method:: doCleanups() |
1134 | 1134 |
1135 This method is called uncoditionally after :meth:`tearDown`, or | 1135 This method is called unconditionally after :meth:`tearDown`, or |
1136 after :meth:`setUp` if :meth:`setUp` raises an exception. | 1136 after :meth:`setUp` if :meth:`setUp` raises an exception. |
1137 | 1137 |
1138 It is responsible for calling all the cleanup functions added by | 1138 It is responsible for calling all the cleanup functions added by |
1139 :meth:`addCleanup`. If you need cleanup functions to be called | 1139 :meth:`addCleanup`. If you need cleanup functions to be called |
1140 *prior* to :meth:`tearDown` then you can call :meth:`doCleanups` | 1140 *prior* to :meth:`tearDown` then you can call :meth:`doCleanups` |
1141 yourself. | 1141 yourself. |
1142 | 1142 |
1143 :meth:`doCleanups` pops methods off the stack of cleanup | 1143 :meth:`doCleanups` pops methods off the stack of cleanup |
1144 functions one at a time, so it can be called at any time. | 1144 functions one at a time, so it can be called at any time. |
1145 | 1145 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1668 Because the pattern is passed into ``load_tests`` the package is free to | 1668 Because the pattern is passed into ``load_tests`` the package is free to |
1669 continue (and potentially modify) test discovery. A 'do nothing' | 1669 continue (and potentially modify) test discovery. A 'do nothing' |
1670 ``load_tests`` function for a test package would look like:: | 1670 ``load_tests`` function for a test package would look like:: |
1671 | 1671 |
1672 def load_tests(loader, standard_tests, pattern): | 1672 def load_tests(loader, standard_tests, pattern): |
1673 # top level directory cached on loader instance | 1673 # top level directory cached on loader instance |
1674 this_dir = os.path.dirname(__file__) | 1674 this_dir = os.path.dirname(__file__) |
1675 package_tests = loader.discover(start_dir=this_dir, pattern=pattern) | 1675 package_tests = loader.discover(start_dir=this_dir, pattern=pattern) |
1676 standard_tests.addTests(package_tests) | 1676 standard_tests.addTests(package_tests) |
1677 return standard_tests | 1677 return standard_tests |
OLD | NEW |