Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(122447)

Delta Between Two Patch Sets: Doc/library/unittest.rst

Issue 17457: Unittest discover fails with namespace packages and builtin modules
Left Patch Set: Created 6 years, 8 months ago
Right Patch Set: Created 5 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 234
235 Test Discovery 235 Test Discovery
236 -------------- 236 --------------
237 237
238 .. versionadded:: 3.2 238 .. versionadded:: 3.2
239 239
240 Unittest supports simple test discovery. In order to be compatible with test 240 Unittest supports simple test discovery. In order to be compatible with test
241 discovery, all of the test files must be :ref:`modules <tut-modules>` or 241 discovery, all of the test files must be :ref:`modules <tut-modules>` or
242 :ref:`packages <tut-packages>` importable from the top-level directory of 242 :ref:`packages <tut-packages>` importable from the top-level directory of
243 the project (this means that their filenames must be valid 243 the project (this means that their filenames must be valid
244 :ref:`identifiers <identifiers>`). 244 :ref:`identifiers <identifiers>`).
245
246 Also, discovery works with namespace packages (:pep:`420`) as well.
247 If a package can't be imported as a normal package, then the namespace
248 fallback will be used.
245 249
246 Test discovery is implemented in :meth:`TestLoader.discover`, but can also be 250 Test discovery is implemented in :meth:`TestLoader.discover`, but can also be
247 used from the command line. The basic command-line usage is:: 251 used from the command line. The basic command-line usage is::
248 252
249 cd project_directory 253 cd project_directory
250 python -m unittest discover 254 python -m unittest discover
251 255
252 .. note:: 256 .. note::
253 257
254 As a shortcut, ``python -m unittest`` is the equivalent of 258 As a shortcut, ``python -m unittest`` is the equivalent of
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 1657
1654 .. versionchanged:: 3.4 1658 .. versionchanged:: 3.4
1655 Modules that raise :exc:`SkipTest` on import are recorded as skips, 1659 Modules that raise :exc:`SkipTest` on import are recorded as skips,
1656 not errors. 1660 not errors.
1657 1661
1658 .. versionchanged:: 3.4 1662 .. versionchanged:: 3.4
1659 Paths are sorted before being imported to ensure execution order for a 1663 Paths are sorted before being imported to ensure execution order for a
1660 given test suite is the same even if the underlying file system's order ing 1664 given test suite is the same even if the underlying file system's order ing
1661 is not dependent on file name like in ext3/4. 1665 is not dependent on file name like in ext3/4.
1662 1666
1667 .. versionchanged:: 3.4
1668 Test discovery supports namespace packages (:pep:`420`).
1669
1663 1670
1664 The following attributes of a :class:`TestLoader` can be configured either by 1671 The following attributes of a :class:`TestLoader` can be configured either by
1665 subclassing or assignment on an instance: 1672 subclassing or assignment on an instance:
1666 1673
1667 1674
1668 .. attribute:: testMethodPrefix 1675 .. attribute:: testMethodPrefix
1669 1676
1670 String giving the prefix of method names which will be interpreted as test 1677 String giving the prefix of method names which will be interpreted as test
1671 methods. The default value is ``'test'``. 1678 methods. The default value is ``'test'``.
1672 1679
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 2205
2199 .. function:: removeHandler(function=None) 2206 .. function:: removeHandler(function=None)
2200 2207
2201 When called without arguments this function removes the control-c handler 2208 When called without arguments this function removes the control-c handler
2202 if it has been installed. This function can also be used as a test decorator 2209 if it has been installed. This function can also be used as a test decorator
2203 to temporarily remove the handler whilst the test is being executed:: 2210 to temporarily remove the handler whilst the test is being executed::
2204 2211
2205 @unittest.removeHandler 2212 @unittest.removeHandler
2206 def test_signal_handling(self): 2213 def test_signal_handling(self):
2207 ... 2214 ...
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+