Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Parse the test case docstring using `pydoc.splitdoc`. | cfc063a9843f74bb0fcf2a18ed6d3ea38cb53d8e | Ben Finney | 2017-05-01 06:44:40 |
Add test cases for test case docstring with surrounding newlines. | aa3e95ae60a1c0348f232eae9ad3edd458c95ff3 | Ben Finney | 2017-05-01 06:01:49 |
Add test cases for stripping surrounding space for shortDescription. | 38e9d6d9d77a436951700754240c13f7b1a933a0 | Ben Finney | 2017-05-01 06:01:13 |
Add test cases for single-line test case docstring. | 4b78af6d79c868fd9658258a122fc2ef28876c35 | Ben Finney | 2017-05-01 06:41:43 |
Comment as to why docs are built against Python 3.6 (#1550) | 31b3901a078774b28a88dc410376c46e28c52c9c | Brett Cannon | 2017-05-11 17:45:34 |
bpo-30308: Code coverage for argument in random.shuffle (#1504) | f111fd2e65ef7aefd4ebeadbb48e84d609bf3733 | csabella | 2017-05-11 15:19:35 |
bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1097) | 991adca012f5e106c2d4040ce619c696ba6f9c46 | INADA Naoki | 2017-05-11 12:18:38 |
#30190: fix invalid escape sequence warnings (#1534) | c4750959acbfc3057f12aaec832483ba30898d1c | Giampaolo Rodola | 2017-05-10 18:13:20 |
bpo-28787: Fix out of tree --with-dtrace builds (#135) | f6eae5bf1c5d7b83e5d5bdbecfff928e478c1cfd | stratakis | 2017-05-10 15:08:15 |
bpo-30281: Fix the default value for stop in PySlice_Unpack() (#1480) | 2ddf5a19c3a06978edff2c8ba0aaf5df3528204a | Xiang Zhang | 2017-05-10 10:19:41 |
bpo-30298: Weaken the condition of deprecation warnings for inline modifiers. (#1490) | 305ccbe27ea5ba82fd2d8c32ec739f980e524330 | Serhiy Storchaka | 2017-05-10 03:05:20 |
bpo-30320: test_eintr now uses pthread_sigmask() (#1523) | 211a392cc15f9a7b1b8ce65d8f6c9f8237d1b77f | Victor Stinner | 2017-05-10 00:37:42 |
PCbuild/build.bat: pass command line parameters when building PGO (#1510) | 291557e2904fa149ee3d56142f41acf63c47fea3 | Charles | 2017-05-09 21:58:48 |
bpo-30285: Optimize case-insensitive matching and searching (#1482) | 6d336a027913327fc042b0d758a16724fea27b9c | Serhiy Storchaka | 2017-05-09 20:37:14 |
bpo-30024: Circular imports involving absolute imports with binding (#1264) | f93234bb8a87855f295d441524e519481ce6ab13 | Serhiy Storchaka | 2017-05-09 19:31:05 |
bpo-30273: update distutils.sysconfig for venv's created from Python (#1515) | dbdea629e2e0e4bd8845aa55041e0a0ca4172cf3 | Jeremy Kloth | 2017-05-09 15:24:13 |
bpo-30258: regrtest: Fix run_tests_multiprocess() (#1479) | 74683fc6247c522ae955a6e7308b8ff51def35d8 | Victor Stinner | 2017-05-09 09:34:01 |
bpo-29990: Fix range checking in GB18030 decoder (#1495) | 9da408d15bdef624a5632182cb4edf98001fa82f | Xiang Zhang | 2017-05-09 03:38:32 |
bpo-30289: remove Misc/python-config.sh when make distclean (#1498) | fa5abac1e6cd74979557d5a6f960a55f40a10b0e | Xiang Zhang | 2017-05-09 02:32:13 |
bpo-29979: Rewrite cgi.parse_multipart to make it consistent with FieldStorage (#991) | cc3fa204d357be5fafc10eb8c2a80fe0bca998f1 | Pierre Quentel | 2017-05-08 12:08:34 |
File | Lines added | Lines deleted |
---|---|---|
Lib/unittest/case.py | 23 | 11 |
File Lib/unittest/case.py changed (mode: 100644) (index 993aaec194..e27cba1efd) | |||
... | ... | import functools | |
5 | 5 | import difflib | import difflib |
6 | 6 | import logging | import logging |
7 | 7 | import pprint | import pprint |
8 | import pydoc | ||
8 | 9 | import re | import re |
9 | 10 | import warnings | import warnings |
10 | 11 | import collections | import collections |
... | ... | class _AssertLogsContext(_BaseTestCaseContext): | |
338 | 339 | .format(logging.getLevelName(self.level), self.logger.name)) | .format(logging.getLevelName(self.level), self.logger.name)) |
339 | 340 | ||
340 | 341 | ||
342 | def short_description_from_docstring(text): | ||
343 | """ | ||
344 | Return the test case short description from a docstring. | ||
345 | |||
346 | The docstring is parsed by the standard `pydoc.splitdoc` function | ||
347 | into (`synopsis`, `long_description`). | ||
348 | |||
349 | If there is no `synopsis`, return None. | ||
350 | """ | ||
351 | if text: | ||
352 | (synopsis, long_description) = pydoc.splitdoc(text) | ||
353 | synopsis = synopsis.strip() | ||
354 | else: | ||
355 | # The text is either an empty string, or some other false value. | ||
356 | synopsis = None | ||
357 | |||
358 | return synopsis | ||
359 | |||
360 | |||
341 | 361 | class TestCase(object): | class TestCase(object): |
342 | 362 | """A class whose instances are single test cases. | """A class whose instances are single test cases. |
343 | 363 | ||
... | ... | class TestCase(object): | |
463 | 483 | return result.TestResult() | return result.TestResult() |
464 | 484 | ||
465 | 485 | def shortDescription(self): | def shortDescription(self): |
466 | """Returns a one-line description of the test, or None if no | ||
467 | description has been provided. | ||
468 | |||
469 | The default implementation of this method returns the first line of | ||
470 | the specified test method's docstring. | ||
471 | """ | ||
472 | doc = self._testMethodDoc | ||
473 | return doc and doc.split("\n")[0].strip() or None | ||
474 | |||
486 | """ Return a one-line description of the test, if any; otherwise None. """ | ||
487 | return short_description_from_docstring(self._testMethodDoc) | ||
475 | 488 | ||
476 | 489 | def id(self): | def id(self): |
477 | 490 | return "%s.%s" % (strclass(self.__class__), self._testMethodName) | return "%s.%s" % (strclass(self.__class__), self._testMethodName) |
... | ... | class FunctionTestCase(TestCase): | |
1395 | 1408 | def shortDescription(self): | def shortDescription(self): |
1396 | 1409 | if self._description is not None: | if self._description is not None: |
1397 | 1410 | return self._description | return self._description |
1398 | doc = self._testFunc.__doc__ | ||
1399 | return doc and doc.split("\n")[0].strip() or None | ||
1411 | return short_description_from_docstring(self._testFunc.__doc__) | ||
1400 | 1412 | ||
1401 | 1413 | ||
1402 | 1414 | class _SubTest(TestCase): | class _SubTest(TestCase): |