mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Merged revisions 70656,70668-70669,70671,70701,70703,70706 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70656 | georg.brandl | 2009-03-28 14:33:33 -0500 (Sat, 28 Mar 2009) | 2 lines Add a script to fixup rst files if the pre-commit hook rejects them. ........ r70668 | benjamin.peterson | 2009-03-28 22:16:57 -0500 (Sat, 28 Mar 2009) | 1 line a more realistic example ........ r70669 | benjamin.peterson | 2009-03-28 22:31:40 -0500 (Sat, 28 Mar 2009) | 1 line stop the versionchanged directive from hiding the docs ........ r70671 | benjamin.peterson | 2009-03-28 22:39:58 -0500 (Sat, 28 Mar 2009) | 1 line fix consistency ........ r70701 | benjamin.peterson | 2009-03-29 17:27:26 -0500 (Sun, 29 Mar 2009) | 1 line add missing import ........ r70703 | benjamin.peterson | 2009-03-29 21:14:21 -0500 (Sun, 29 Mar 2009) | 1 line fix import ........ r70706 | benjamin.peterson | 2009-03-30 09:42:23 -0500 (Mon, 30 Mar 2009) | 1 line add missing import ........
This commit is contained in:
parent
5879d4122a
commit
ded31c47af
4 changed files with 54 additions and 8 deletions
|
@ -446,12 +446,26 @@ Basic skipping looks like this: ::
|
||||||
def test_nothing(self):
|
def test_nothing(self):
|
||||||
self.fail("shouldn't happen")
|
self.fail("shouldn't happen")
|
||||||
|
|
||||||
|
@unittest.skipIf(mylib.__version__ < (1, 3), "not supported in this library version")
|
||||||
|
def test_format(self):
|
||||||
|
# Tests that work for only a certain version of the library.
|
||||||
|
pass
|
||||||
|
|
||||||
|
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
|
||||||
|
def test_windows_support(self):
|
||||||
|
# windows specific testing code
|
||||||
|
pass
|
||||||
|
|
||||||
This is the output of running the example above in verbose mode: ::
|
This is the output of running the example above in verbose mode: ::
|
||||||
|
|
||||||
|
test_format (__main__.MyTestCase) ... skipped 'not supported in this library version'
|
||||||
test_nothing (__main__.MyTestCase) ... skipped 'demonstrating skipping'
|
test_nothing (__main__.MyTestCase) ... skipped 'demonstrating skipping'
|
||||||
|
test_windows_support (__main__.MyTestCase) ... skipped 'requires Windows'
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Ran 1 test in 0.072s
|
Ran 3 tests in 0.005s
|
||||||
|
|
||||||
|
OK (skipped=3)
|
||||||
|
|
||||||
Classes can be skipped just like methods: ::
|
Classes can be skipped just like methods: ::
|
||||||
|
|
||||||
|
@ -657,13 +671,15 @@ Test cases
|
||||||
To catch any of a group of exceptions, a tuple containing the exception
|
To catch any of a group of exceptions, a tuple containing the exception
|
||||||
classes may be passed as *exception*.
|
classes may be passed as *exception*.
|
||||||
|
|
||||||
|
If *callable* is omitted or None, returns a context manager so that the
|
||||||
|
code under test can be written inline rather than as a function::
|
||||||
|
|
||||||
|
with self.failUnlessRaises(some_error_class):
|
||||||
|
do_something()
|
||||||
|
|
||||||
.. versionchanged:: 3.1
|
.. versionchanged:: 3.1
|
||||||
|
Added the ability to use :meth:`assertRaises` as a context manager.
|
||||||
|
|
||||||
If *callable* is omitted or None, returns a context manager so that the
|
|
||||||
code under test can be written inline rather than as a function::
|
|
||||||
|
|
||||||
with self.failUnlessRaises(some_error_class):
|
|
||||||
do_something()
|
|
||||||
|
|
||||||
.. method:: failIf(expr[, msg])
|
.. method:: failIf(expr[, msg])
|
||||||
assertFalse(expr[, msg])
|
assertFalse(expr[, msg])
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# email package unit tests for (optional) Asian codecs
|
# email package unit tests for (optional) Asian codecs
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import TestSkipped, run_unittest
|
from test.support import run_unittest
|
||||||
|
|
||||||
from email.test.test_email import TestEmailBase
|
from email.test.test_email import TestEmailBase
|
||||||
from email.charset import Charset
|
from email.charset import Charset
|
||||||
|
@ -15,7 +15,7 @@ from email.message import Message
|
||||||
try:
|
try:
|
||||||
str('foo', 'euc-jp')
|
str('foo', 'euc-jp')
|
||||||
except LookupError:
|
except LookupError:
|
||||||
raise TestSkipped
|
raise unittest.SkipTest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import unittest
|
||||||
from test.fork_wait import ForkWait
|
from test.fork_wait import ForkWait
|
||||||
from test.support import run_unittest, reap_children
|
from test.support import run_unittest, reap_children
|
||||||
|
|
||||||
|
|
29
Tools/scripts/reindent-rst.py
Executable file
29
Tools/scripts/reindent-rst.py
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# Make a reST file compliant to our pre-commit hook.
|
||||||
|
# Currently just remove trailing whitespace.
|
||||||
|
|
||||||
|
from __future__ import with_statement
|
||||||
|
import sys, re, shutil
|
||||||
|
|
||||||
|
ws_re = re.compile(r'\s+(\r?\n)$')
|
||||||
|
|
||||||
|
def main(argv=sys.argv):
|
||||||
|
rv = 0
|
||||||
|
for filename in argv[1:]:
|
||||||
|
try:
|
||||||
|
with open(filename, 'rb') as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
new_lines = [ws_re.sub(r'\1', line) for line in lines]
|
||||||
|
if new_lines != lines:
|
||||||
|
print 'Fixing %s...' % filename
|
||||||
|
shutil.copyfile(filename, filename + '.bak')
|
||||||
|
with open(filename, 'wb') as f:
|
||||||
|
f.writelines(new_lines)
|
||||||
|
except Exception, err:
|
||||||
|
print 'Cannot fix %s: %s' % (filename, err)
|
||||||
|
rv = 1
|
||||||
|
return rv
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
Loading…
Add table
Add a link
Reference in a new issue